Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2022-12-05 05:39:54
Exec Total Coverage
Lines: 8424 16461 51.2%
Functions: 213 315 67.6%
Branches: 6810 19654 34.6%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #ifndef __GTHREAD_HIDE_WIN32API
16 11 #define __GTHREAD_HIDE_WIN32API 1
17 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <string.h>
22 #include <set>
23 #include <stdio.h>
24
25 #include "hero.h"
26 #include "guys.h"
27 #include "subscr.h"
28 #include "zc_subscr.h"
29 #include "decorations.h"
30 #include "gamedata.h"
31 #include "zc_custom.h"
32 #include "title.h"
33 #include "ffscript.h"
34 #include "drawing.h"
35 #include "combos.h"
36 #include "base/zc_math.h"
37 #include "user_object.h"
38 #include "slopes.h"
39 extern FFScript FFCore;
40 extern word combo_doscript[176];
41 extern byte itemscriptInitialised[256];
42 extern HeroClass Hero;
43 extern ZModule zcm;
44 extern zcmodule moduledata;
45 extern refInfo playerScriptData;
46 #include "zscriptversion.h"
47 #include "particles.h"
48 #include <fmt/format.h>
49
50 extern refInfo itemScriptData[256];
51 extern refInfo itemCollectScriptData[256];
52 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
53 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
54 extern refInfo *ri; //= NULL;
55 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
56 extern byte dmapscriptInitialised;
57 extern word item_doscript[256];
58 extern word item_collect_doscript[256];
59 extern portal* mirror_portal;
60 using std::set;
61
62 extern int32_t skipcont;
63
64 extern int32_t draw_screen_clip_rect_x1;
65 extern int32_t draw_screen_clip_rect_x2;
66 extern int32_t draw_screen_clip_rect_y1;
67 extern int32_t draw_screen_clip_rect_y2;
68 extern word global_wait;
69 extern bool player_waitdraw;
70 extern bool dmap_waitdraw;
71 extern bool passive_subscreen_waitdraw;
72 extern bool active_subscreen_waitdraw;
73
74 int32_t hero_count = -1;
75 int32_t hero_animation_speed = 1; //lower is faster animation
76 int32_t z3step = 2;
77 11 static zfix hero_newstep(1.5);
78 11 static zfix hero_newstep_diag(1.5);
79 bool did_scripta=false;
80 bool did_scriptb=false;
81 bool did_scriptl=false;
82 byte lshift = 0;
83 int32_t dowpn = -1;
84 int32_t directItem = -1; //Is set if Hero is currently using an item directly
85 int32_t directItemA = -1;
86 int32_t directItemB = -1;
87 int32_t directItemX = -1;
88 int32_t directItemY = -1;
89 int32_t directWpn = -1;
90 int32_t whistleitem=-1;
91 extern word g_doscript;
92 extern word player_doscript;
93 extern word dmap_doscript;
94 extern word passive_subscreen_doscript;
95 extern byte epilepsyFlashReduction;
96 extern int32_t script_hero_cset;
97
98 void playLevelMusic();
99
100 extern particle_list particles;
101
102 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
103
104 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
105 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
106 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
107 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
108
109 4878164 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
110 {
111
2/2
✓ Branch 0 taken 9138 times.
✓ Branch 1 taken 4869026 times.
4878164 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
112 4869026 return false;
113 4878164 }
114
115 1630238 static inline bool platform_fallthrough(bool doslopecheck = true)
116 {
117
5/6
✓ Branch 0 taken 1630238 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625002 times.
✓ Branch 3 taken 5236 times.
✓ Branch 4 taken 1622904 times.
✓ Branch 5 taken 2098 times.
4421058 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
118
2/2
✓ Branch 0 taken 236825 times.
✓ Branch 1 taken 231589 times.
1630238 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
119
6/6
✓ Branch 0 taken 1161203 times.
✓ Branch 1 taken 1398028 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 1629456 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 23 times.
468414 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
120 }
121
122 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
123 {
124 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
125 if(slopesmisc == 2) return false;
126 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
127 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
128 if (platform_fallthrough() && !ignoreFallthrough) return false;
129 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
130 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
131 return true;
132 return false;
133 }
134
135 2065476 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
136 {
137
4/4
✓ Branch 0 taken 76694 times.
✓ Branch 1 taken 1988782 times.
✓ Branch 2 taken 54591 times.
✓ Branch 3 taken 22103 times.
2065476 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
138
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 2041403 times.
2043373 if(slopesmisc == 2) return false;
139
4/4
✓ Branch 0 taken 1664016 times.
✓ Branch 1 taken 377387 times.
✓ Branch 2 taken 33409 times.
✓ Branch 3 taken 1630607 times.
2041403 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
140
6/6
✓ Branch 0 taken 1903 times.
✓ Branch 1 taken 1628704 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 1411 times.
✓ Branch 4 taken 121 times.
✓ Branch 5 taken 371 times.
1630607 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
141
4/4
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 1629592 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 551 times.
1630236 if (platform_fallthrough() && !ignoreFallthrough) return false;
142
4/4
✓ Branch 0 taken 35728 times.
✓ Branch 1 taken 1593957 times.
✓ Branch 2 taken 34074 times.
✓ Branch 3 taken 1654 times.
1629685 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
143
6/6
✓ Branch 0 taken 479490 times.
✓ Branch 1 taken 1148541 times.
✓ Branch 2 taken 457571 times.
✓ Branch 3 taken 21919 times.
✓ Branch 4 taken 196 times.
✓ Branch 5 taken 457375 times.
1628031 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
144 22115 return true;
145 1605916 return false;
146 2065476 }
147
148
149 5765460 bool usingActiveShield(int32_t itmid)
150 {
151
2/2
✓ Branch 0 taken 4733942 times.
✓ Branch 1 taken 1031518 times.
5765460 switch(Hero.action) //filter allowed actions
152 {
153 case none: case walking: case rafting:
154 case gothit: case swimhit:
155 4733942 break;
156 1031518 default: return false;
157 }
158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4733942 times.
4733942 if(itmid < 0)
159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4733942 times.
4733942 itmid = (Hero.active_shield_id < 0
160 4733942 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
161
2/2
✓ Branch 0 taken 4729069 times.
✓ Branch 1 taken 4873 times.
4733942 if(itmid < 0) return false;
162
1/2
✓ Branch 0 taken 4729069 times.
✗ Branch 1 not taken.
4729069 if(!checkitem_jinx(itmid)) return false;
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4729069 times.
4729069 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
164 if(!isItmPressed(itmid)) return false;
165 return (checkbunny(itmid) && checkmagiccost(itmid));
166 5765460 }
167 3425116 int32_t getCurrentShield(bool requireActive)
168 {
169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3425116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3425116 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
170 return Hero.active_shield_id;
171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3425116 times.
3425116 if(!requireActive) return current_item_id(itype_shield);
172 return -1;
173 3425116 }
174 6732 int32_t getCurrentActiveShield()
175 {
176 6732 int32_t id = Hero.active_shield_id;
177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6732 if(id > -1 && usingActiveShield(id))
178 return id;
179 6732 return -1;
180 6732 }
181 1981854 int32_t refreshActiveShield()
182 {
183 1981854 int32_t id = -1;
184
2/2
✓ Branch 0 taken 1908056 times.
✓ Branch 1 taken 73798 times.
1981854 if(DrunkcBbtn())
185 {
186 73798 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73798 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
188 {
189 id = Bwpn&0xFFF;
190 }
191 73798 }
192
3/4
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1698080 times.
✓ Branch 3 taken 283774 times.
1981854 if(id < 0 && DrunkcAbtn())
193 {
194 283774 itemdata const& dat = itemsbuf[Awpn&0xFFF];
195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 283774 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
283774 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
196 {
197 id = Awpn&0xFFF;
198 }
199 283774 }
200
2/4
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981854 times.
✗ Branch 3 not taken.
1981854 if(id < 0 && DrunkcEx1btn())
201 {
202 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
203 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
204 {
205 id = Xwpn&0xFFF;
206 }
207 }
208
2/4
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981854 times.
✗ Branch 3 not taken.
1981854 if(id < 0 && DrunkcEx2btn())
209 {
210 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
211 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
212 {
213 id = Ywpn&0xFFF;
214 }
215 }
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981854 times.
1981854 if(!usingActiveShield(id))
217 1981854 return -1;
218 return id;
219 1981854 }
220 static bool is_immobile()
221 {
222 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
223 return false;
224 zfix rate(Hero.steprate);
225 int32_t shieldid = getCurrentActiveShield();
226 if(shieldid > -1)
227 {
228 itemdata const& shield = itemsbuf[shieldid];
229 if(shield.flags & ITEM_FLAG10) //Change Speed flag
230 {
231 zfix perc = shield.misc7;
232 perc /= 100;
233 if(perc < 0)
234 perc = (perc*-1)+1;
235 rate = (rate * perc) + shield.misc8;
236 }
237 }
238 return rate != 0;
239 }
240
241 1990822 bool HeroClass::isStanding(bool forJump)
242 {
243
11/14
✓ Branch 0 taken 1990582 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 1990582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12204 times.
✓ Branch 5 taken 1978378 times.
✓ Branch 6 taken 3848 times.
✓ Branch 7 taken 8356 times.
✓ Branch 8 taken 3848 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3848 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 557 times.
✓ Branch 13 taken 3291 times.
1990822 bool st = (z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !ladderx && !laddery && !getOnSideviewLadder()) && hoverclk==0);
244
2/2
✓ Branch 0 taken 1987291 times.
✓ Branch 1 taken 3531 times.
1990822 if(!st) return false;
245 1987291 int32_t val = check_pitslide();
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1987291 times.
1987291 if(val == -2) return false;
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1987291 times.
1987291 if(val == -1) return true;
248 return forJump;
249 1990822 }
250 9332 bool HeroClass::isLifting()
251 {
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 if(lift_wpn) return true;
253 9332 return false;
254 9332 }
255
256 15100 void HeroClass::set_respawn_point(bool setwarp)
257 {
258
2/2
✓ Branch 0 taken 12256 times.
✓ Branch 1 taken 2844 times.
15100 if(setwarp)
259 {
260 2844 warpx = x;
261 2844 warpy = y;
262 2844 raftwarpx = x;
263 2844 raftwarpy = y;
264 2844 }
265
2/2
✓ Branch 0 taken 5545 times.
✓ Branch 1 taken 9555 times.
15100 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
266 {
267
2/2
✓ Branch 0 taken 9330 times.
✓ Branch 1 taken 225 times.
9555 switch(action)
268 {
269 case none: case walking:
270 9330 break;
271 default:
272 225 return; //Not a 'safe action'
273 }
274
4/6
✓ Branch 0 taken 9210 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 9210 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9210 times.
9330 if(z > 0 || fakez > 0 || hoverclk) return; //in air
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9210 times.
9210 if(check_pitslide(true) != -1) return; //On a pit
276
277 { //Check water
278 9210 int32_t water = 0;
279 9210 int32_t types[4] = {0};
280 9210 int32_t x1 = x+4, x2 = x+11,
281 9210 y1 = y+9, y2 = y+15;
282
1/2
✓ Branch 0 taken 9210 times.
✗ Branch 1 not taken.
9210 if (get_bit(quest_rules, qr_SMARTER_WATER))
283 {
284
3/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 9163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
9214 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
285
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 43 times.
47 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
286
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
287 4 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
288 9210 }
289 else
290 {
291 types[0] = COMBOTYPE(x1,y1);
292
293 if(MAPFFCOMBO(x1,y1))
294 types[0] = FFCOMBOTYPE(x1,y1);
295
296 types[1] = COMBOTYPE(x1,y2);
297
298 if(MAPFFCOMBO(x1,y2))
299 types[1] = FFCOMBOTYPE(x1,y2);
300
301 types[2] = COMBOTYPE(x2,y1);
302
303 if(MAPFFCOMBO(x2,y1))
304 types[2] = FFCOMBOTYPE(x2,y1);
305
306 types[3] = COMBOTYPE(x2,y2);
307
308 if(MAPFFCOMBO(x2,y2))
309 types[3] = FFCOMBOTYPE(x2,y2);
310
311 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
312 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
313 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
314
315 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
316 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
317 water = typec;
318 }
319
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9206 times.
9210 if(water > 0)
320 {
321 4 return;
322 }
323 } //End check water
324
325 46030 int poses[4] = {
326 9206 COMBOPOS(x,y+(bigHitbox?0:8)),
327 9206 COMBOPOS(x,y+15),
328 9206 COMBOPOS(x+15,y+(bigHitbox?0:8)),
329 9206 COMBOPOS(x+15,y+15)
330 };
331
2/2
✓ Branch 0 taken 36824 times.
✓ Branch 1 taken 9206 times.
46030 for(auto pos : poses)
332 {
333
1/2
✓ Branch 0 taken 36824 times.
✗ Branch 1 not taken.
36824 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
334 return;
335 }
336 9206 }
337 14751 respawn_x = x;
338 14751 respawn_y = y;
339 14751 respawn_scr = currscr;
340 14751 respawn_dmap = currdmap;
341 15100 }
342
343 3 void HeroClass::go_respawn_point()
344 {
345 3 x = respawn_x;
346 3 y = respawn_y;
347 3 can_mirror_portal = false; //incase entry is on a portal!
348 3 warpx=x;
349 3 warpy=y;
350 3 raftwarpx = x;
351 3 raftwarpy = y;
352 3 trySideviewLadder(); //Cling to ladder automatically
353
354
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
355 return; //No cross-screen return
356
357
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if(currdmap != respawn_dmap || currscr != respawn_scr)
358 {
359 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
360 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
361 }
362 3 }
363
364 3057 void HeroClass::trySideviewLadder()
365 {
366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3057 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
367 setOnSideviewLadder(true);
368 3057 }
369
370 9136023 bool HeroClass::can_pitfall(bool ignore_hover)
371 {
372
23/30
✓ Branch 0 taken 9106664 times.
✓ Branch 1 taken 29359 times.
✓ Branch 2 taken 9086744 times.
✓ Branch 3 taken 19920 times.
✓ Branch 4 taken 9086504 times.
✓ Branch 5 taken 240 times.
✓ Branch 6 taken 9086504 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9086492 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 9086492 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9086492 times.
✓ Branch 14 taken 9085833 times.
✓ Branch 15 taken 659 times.
✓ Branch 16 taken 9085833 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 9085833 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 9085833 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 8913465 times.
✓ Branch 23 taken 172368 times.
✓ Branch 24 taken 8913185 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 8913185 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 768 times.
✓ Branch 29 taken 8912417 times.
9136023 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
373 }
374
375 1131888 int32_t HeroClass::DrunkClock()
376 {
377 1131888 return drunkclk;
378 }
379 void HeroClass::setDrunkClock(int32_t newdrunkclk)
380 {
381 drunkclk=newdrunkclk;
382 }
383
384 int32_t HeroClass::StunClock()
385 {
386 return lstunclock;
387 }
388 void HeroClass::setStunClock(int32_t v)
389 {
390 lstunclock=v;
391 }
392
393 26185542 int32_t HeroClass::BunnyClock()
394 {
395 26185542 return lbunnyclock;
396 }
397 void HeroClass::setBunnyClock(int32_t v)
398 {
399 lbunnyclock=v;
400 }
401
402
9/18
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 11 times.
✗ Branch 17 not taken.
44 HeroClass::HeroClass() : sprite()
403 33 {
404 11 lift_wpn = nullptr;
405
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 init();
406 22 }
407
408 //2.6
409
410 //Stop the subscreen from falling. -Z
411
412 221 bool HeroClass::stopSubscreenFalling(){
413 221 return preventsubscreenfalling;
414 }
415
416 void HeroClass::stopSubscreenFalling(bool v){
417 preventsubscreenfalling = v;
418 }
419
420
421 //Set the button items by brute force
422
423 void HeroClass::setAButtonItem(int32_t itmslot){
424 game->awpn = itmslot;
425 }
426
427 void HeroClass::setBButtonItem(int32_t itmslot){
428 game->bwpn = itmslot;
429 }
430
431 1981862 void HeroClass::ClearhitHeroUIDs()
432 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
433 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
434 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
435 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
436 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
437 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
438 //clear it on the next frame, but that had the SAME outcome.
439 //Where and how can I clear a value at the end of every frame, so that:
440 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
441 // 2. FFCs can read it before Waitframe. --same.
442 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
443
2/2
✓ Branch 0 taken 15854896 times.
✓ Branch 1 taken 1981862 times.
17836758 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED_PLAYER; q++ )
444 {
445 /*
446 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
447 {
448 //Z_scripterrlog("frame is: %d\n", frame);
449 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
450 lastHitBy[q][0] = 0;
451 }
452 */
453 15854896 lastHitBy[q][0] = 0;
454 15854896 }
455 1981862 }
456
457 4550 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
458 {
459 4550 lastHitBy[type][0] = screen_index;
460 //lastHitBy[type][1] = frame;
461 /* Let's figure out how to clear this...
462 if ( global_wait ) lastHitBy[type] = screen_index;
463 else lastHitBy[type] = 0;
464 //No, we clear it in Zelda.cpp, with this:
465 if(global_wait)
466 {
467 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
468 global_wait=false;
469 }
470
471
472 draw_screen(tmpscr);
473
474 //clear Hero's last hits
475 //for ( int32_t q = 0; q < 4; q++ ) Hero.sethitHeroUID(q, 0);
476
477 */
478
479 4550 }
480
481 int32_t HeroClass::gethitHeroUID(int32_t type)
482 {
483 return lastHitBy[type][0];
484 }
485
486 void HeroClass::set_defence(int32_t type, int32_t v)
487 {
488 defence[type] = v;
489 }
490
491 int32_t HeroClass::get_defence(int32_t type)
492 {
493 return defence[type];
494 }
495
496
497 //Set Hero;s hurt sfx
498 void HeroClass::setHurtSFX(int32_t sfx)
499 {
500 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
501 }
502 2314 int32_t HeroClass::getHurtSFX()
503 {
504 2314 return QMisc.miscsfx[sfxHURTPLAYER];
505 }
506
507 bool HeroClass::getDiagMove()
508 {
509 return diagonalMovement;
510 }
511 void HeroClass::setDiagMove(bool newdiag)
512 {
513 diagonalMovement=newdiag;
514 }
515 bool HeroClass::getBigHitbox()
516 {
517 return bigHitbox;
518 }
519 97 void HeroClass::setBigHitbox(bool newbigHitbox)
520 {
521 97 bigHitbox=newbigHitbox;
522 97 syofs = bigHitbox?0:8;
523 97 sysz_ofs = bigHitbox?0:-8;
524 97 }
525 int32_t HeroClass::getStepRate()
526 {
527 return steprate;
528 }
529 void HeroClass::setStepRate(int32_t newrate)
530 {
531 steprate = newrate;
532 }
533 int32_t HeroClass::getSwimUpRate()
534 {
535 return game->get_sideswim_up();
536 }
537 void HeroClass::setSwimUpRate(int32_t newrate)
538 {
539 game->set_sideswim_up(newrate);
540 }
541 int32_t HeroClass::getSwimSideRate()
542 {
543 return game->get_sideswim_side();
544 }
545 void HeroClass::setSwimSideRate(int32_t newrate)
546 {
547 game->set_sideswim_side(newrate);
548 }
549 int32_t HeroClass::getSwimDownRate()
550 {
551 return game->get_sideswim_down();
552 }
553 void HeroClass::setSwimDownRate(int32_t newrate)
554 {
555 game->set_sideswim_down(newrate);
556 }
557
558
559 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
560 1477553 void HeroClass::herostep()
561 {
562
2/2
✓ Branch 0 taken 1346536 times.
✓ Branch 1 taken 131017 times.
1477553 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
563 //need to run all global/hero/dmap scripts here?
564 1477553 }
565
566 9944 bool is_moving()
567 {
568
6/6
✓ Branch 0 taken 8958 times.
✓ Branch 1 taken 986 times.
✓ Branch 2 taken 7164 times.
✓ Branch 3 taken 1794 times.
✓ Branch 4 taken 4701 times.
✓ Branch 5 taken 2463 times.
9944 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
569 }
570
571 // called by ALLOFF()
572 3705 void HeroClass::resetflags(bool all)
573 {
574 3705 refilling=REFILL_NONE;
575 3705 inwallm=false;
576 3705 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
577 3705 usecounts.clear();
578
579
4/4
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 3627 times.
3705 if(swordclk>0 || all)
580 {
581 78 swordclk=0;
582 78 verifyAWpn();
583 78 }
584
4/4
✓ Branch 0 taken 3701 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 3640 times.
3705 if(itemclk>0 || all)
585 65 itemclk=0;
586
587
2/2
✓ Branch 0 taken 3644 times.
✓ Branch 1 taken 61 times.
3705 if(all)
588 {
589 61 NayrusLoveShieldClk=0;
590
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(nayruitem != -1)
592 {
593 stop_sfx(itemsbuf[nayruitem].usesound);
594 stop_sfx(itemsbuf[nayruitem].usesound+1);
595 }
596
597 61 nayruitem = -1;
598 61 hoverclk=jumping=0;
599 61 hoverflags = 0;
600 61 }
601 3705 damageovertimeclk = 0;
602 3705 newconveyorclk = 0;
603 3705 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
604
2/2
✓ Branch 0 taken 3705 times.
✓ Branch 1 taken 25935 times.
29640 for(auto q = 0; q < 7; ++q)
605 25935 hooked_undercombos[q] = -1;
606 3705 hopclk=0;
607 3705 hopdir=-1;
608 3705 attackclk=0;
609 3705 stomping=false;
610 3705 reset_swordcharge();
611 3705 diveclk=drownclk=drownCombo=0;
612 3705 action=none; FFCore.setHeroAction(none);
613 3705 conveyor_flags=0;
614 3705 magiccastclk=0;
615 3705 magicitem=-1;
616 3705 }
617
618 //Can use this for Hero->Stun. -Z
619 2369 void HeroClass::Freeze()
620 {
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2369 times.
2369 if (action != inwind)
622 {
623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2369 times.
2369 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
624 2369 else {action=freeze; FFCore.setHeroAction(freeze);}
625 // also cancel Hero's attack
626 2369 attackclk = 0;
627 2369 }
628 2369 }
629 293 void HeroClass::unfreeze()
630 {
631
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
293 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
293 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
633 293 }
634
635 3 void HeroClass::Drown(int32_t state)
636 {
637 // Hero should never drown if the ladder is out
638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ladderx+laddery)
639 return;
640
641 3 drop_liftwpn();
642
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 switch(state)
643 {
644 case 1:
645 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
646 attackclk=0;
647 attack=wNone;
648 attackid=-1;
649 reset_swordcharge();
650 drownclk=64;
651 z=fakez=fall=fakefall=0;
652 break;
653
654
655 default:
656 {
657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
658 3 else {action=drowning; FFCore.setHeroAction(drowning);}
659 3 attackclk=0;
660 3 attack=wNone;
661 3 attackid=-1;
662 3 reset_swordcharge();
663 3 drownclk=64;
664 3 z=fakez=fall=fakefall=0;
665 3 break;
666 }
667 }
668
669 3 }
670
671 203 void HeroClass::finishedmsg()
672 {
673 //these are to cancel out any keys that Hero may
674 //be pressing so he doesn't attack at the end of
675 //a message if he was scrolling through it quickly.
676 203 rAbtn();
677 203 rBbtn();
678 203 unfreeze();
679
680
2/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 203 times.
406 if(action == landhold1 ||
681
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 action == landhold2 ||
682
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 action == waterhold1 ||
683
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 action == waterhold2 ||
684
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 action == sidewaterhold1 ||
685 203 action == sidewaterhold2)
686 {
687 holdclk = 1;
688 }
689 203 }
690 6 void HeroClass::setEaten(int32_t i)
691 {
692 6 inlikelike=i;
693 6 }
694 6 int32_t HeroClass::getEaten()
695 {
696 6 return inlikelike;
697 }
698 999683 zfix HeroClass::getX()
699 {
700 999683 return x;
701 }
702 834661 zfix HeroClass::getY()
703 {
704 834661 return y;
705 }
706 14285773 zfix HeroClass::getZ()
707 {
708 14285773 return z;
709 }
710 10038524 zfix HeroClass::getFakeZ()
711 {
712 10038524 return fakez;
713 }
714 zfix HeroClass::getFall()
715 {
716 return fall;
717 }
718 zfix HeroClass::getFakeFall()
719 {
720 return fakefall;
721 }
722 zfix HeroClass::getXOfs()
723 {
724 return xofs;
725 }
726 zfix HeroClass::getYOfs()
727 {
728 return yofs;
729 }
730 void HeroClass::setXOfs(int32_t newxofs)
731 {
732 xofs=newxofs;
733 }
734 void HeroClass::setYOfs(int32_t newyofs)
735 {
736 yofs=newyofs;
737 }
738 int32_t HeroClass::getHXOfs()
739 {
740 return hxofs;
741 }
742 int32_t HeroClass::getHYOfs()
743 {
744 return hyofs;
745 }
746 int32_t HeroClass::getHXSz()
747 {
748 return hxsz;
749 }
750 int32_t HeroClass::getHYSz()
751 {
752 return hysz;
753 }
754 12096 zfix HeroClass::getClimbCoverX()
755 {
756 12096 return climb_cover_x;
757 }
758 12096 zfix HeroClass::getClimbCoverY()
759 {
760 12096 return climb_cover_y;
761 }
762 int32_t HeroClass::getLadderX()
763 {
764 return ladderx;
765 }
766 int32_t HeroClass::getLadderY()
767 {
768 return laddery;
769 }
770
771 166 void HeroClass::setX(int32_t new_x)
772 {
773 166 zfix dx=new_x-x;
774
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if(Lwpns.idFirst(wHookshot)>-1)
775 {
776 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
777 hs_startx+=(int32_t)dx;
778 }
779
780
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if(Lwpns.idFirst(wHSHandle)>-1)
781 {
782 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
783 }
784
785
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if(chainlinks.Count()>0)
786 {
787 for(int32_t j=0; j<chainlinks.Count(); j++)
788 {
789 chainlinks.spr(j)->x+=dx;
790 }
791 }
792
793 166 x=new_x;
794
795 // A kludge
796
4/4
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 163 times.
✓ Branch 3 taken 2 times.
166 if(!diagonalMovement && dir<=down)
797 2 is_on_conveyor=true;
798 166 }
799
800 166 void HeroClass::setY(int32_t new_y)
801 {
802 166 zfix dy=new_y-y;
803
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if(Lwpns.idFirst(wHookshot)>-1)
804 {
805 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
806 hs_starty+=(int32_t)dy;
807 }
808
809
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if(Lwpns.idFirst(wHSHandle)>-1)
810 {
811 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
812 }
813
814
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if(chainlinks.Count()>0)
815 {
816 for(int32_t j=0; j<chainlinks.Count(); j++)
817 {
818 chainlinks.spr(j)->y+=dy;
819 }
820 }
821
822 166 y=new_y;
823
824 // A kludge
825
4/4
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 163 times.
166 if(!diagonalMovement && dir>=left)
826 163 is_on_conveyor=true;
827 166 }
828
829 void HeroClass::setZ(int32_t new_z)
830 {
831 if(isSideViewHero())
832 return;
833
834 if(z==0 && new_z > 0)
835 {
836 switch(action)
837 {
838 case swimming:
839 {
840 diveclk=0;
841 action=walking; FFCore.setHeroAction(walking);
842 break;
843 }
844
845 case waterhold1:
846 {
847 action=landhold1; FFCore.setHeroAction(landhold1);
848 break;
849 }
850
851 case waterhold2:
852 {
853 action=landhold2; FFCore.setHeroAction(landhold2);
854 break;
855 }
856
857 default:
858 if(charging) //!DIMITODO: Let Hero jump while charging sword
859 {
860 reset_swordcharge();
861 attackclk=0;
862 }
863
864 break;
865 }
866 }
867
868 z=(new_z>0 ? new_z : 0);
869 }
870
871 void HeroClass::setFakeZ(int32_t new_z)
872 {
873 if(isSideViewHero())
874 return;
875
876 if(fakez==0 && new_z > 0)
877 {
878 switch(action)
879 {
880 case swimming:
881 {
882 diveclk=0;
883 action=walking; FFCore.setHeroAction(walking);
884 break;
885 }
886
887 case waterhold1:
888 {
889 action=landhold1; FFCore.setHeroAction(landhold1);
890 break;
891 }
892
893 case waterhold2:
894 {
895 action=landhold2; FFCore.setHeroAction(landhold2);
896 break;
897 }
898
899 default:
900 if(charging) //!DIMITODO: Let Hero jump while charging sword
901 {
902 reset_swordcharge();
903 attackclk=0;
904 }
905
906 break;
907 }
908 }
909
910 fakez=(new_z>0 ? new_z : 0);
911 }
912
913 void HeroClass::setXfix(zfix new_x)
914 {
915 //Z_scripterrlog("setxdbl: %f\n",new_x);
916 zfix dx=new_x-x;
917 if(Lwpns.idFirst(wHookshot)>-1)
918 {
919 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
920 hs_startx+=(int32_t)dx;
921 }
922
923 if(Lwpns.idFirst(wHSHandle)>-1)
924 {
925 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
926 }
927
928 if(chainlinks.Count()>0)
929 {
930 for(int32_t j=0; j<chainlinks.Count(); j++)
931 {
932 chainlinks.spr(j)->x+=dx;
933 }
934 }
935
936 x=new_x;
937
938 // A kludge
939 if(!diagonalMovement && dir<=down)
940 is_on_conveyor=true;
941 }
942
943 void HeroClass::setYfix(zfix new_y)
944 {
945 zfix dy=new_y-y;
946 if(Lwpns.idFirst(wHookshot)>-1)
947 {
948 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
949 hs_starty+=(int32_t)dy;
950 }
951
952 if(Lwpns.idFirst(wHSHandle)>-1)
953 {
954 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
955 }
956
957 if(chainlinks.Count()>0)
958 {
959 for(int32_t j=0; j<chainlinks.Count(); j++)
960 {
961 chainlinks.spr(j)->y+=dy;
962 }
963 }
964
965 y=new_y;
966
967 // A kludge
968 if(!diagonalMovement && dir>=left)
969 is_on_conveyor=true;
970 }
971
972 void HeroClass::setZfix(zfix new_z)
973 {
974 if(isSideViewHero())
975 return;
976
977 if(z==0 && new_z > 0)
978 {
979 switch(action)
980 {
981 case swimming:
982 {
983 diveclk=0;
984 action=walking; FFCore.setHeroAction(walking);
985 break;
986 }
987
988 case waterhold1:
989 {
990 action=landhold1; FFCore.setHeroAction(landhold1);
991 break;
992 }
993
994 case waterhold2:
995 {
996 action=landhold2; FFCore.setHeroAction(landhold2);
997 break;
998 }
999
1000 default:
1001 if(charging) //!DIMITODO: Let Hero jump while charging sword
1002 {
1003 reset_swordcharge();
1004 attackclk=0;
1005 }
1006
1007 break;
1008 }
1009 }
1010
1011 z=(new_z>0 ? new_z : zfix(0));
1012 }
1013
1014 void HeroClass::setFakeZfix(zfix new_z)
1015 {
1016 if(isSideViewHero())
1017 return;
1018
1019 if(fakez==0 && new_z > 0)
1020 {
1021 switch(action)
1022 {
1023 case swimming:
1024 {
1025 diveclk=0;
1026 action=walking; FFCore.setHeroAction(walking);
1027 break;
1028 }
1029
1030 case waterhold1:
1031 {
1032 action=landhold1; FFCore.setHeroAction(landhold1);
1033 break;
1034 }
1035
1036 case waterhold2:
1037 {
1038 action=landhold2; FFCore.setHeroAction(landhold2);
1039 break;
1040 }
1041
1042 default:
1043 if(charging) //!DIMITODO: Let Hero jump while charging sword
1044 {
1045 reset_swordcharge();
1046 attackclk=0;
1047 }
1048
1049 break;
1050 }
1051 }
1052
1053 fakez=(new_z>0 ? new_z : zfix(0));
1054 }
1055
1056 39 void HeroClass::setFall(zfix new_fall)
1057 {
1058 39 fall=new_fall;
1059 39 jumping=-1;
1060 39 }
1061 void HeroClass::setFakeFall(zfix new_fall)
1062 {
1063 fakefall=new_fall;
1064 jumping=-1;
1065 }
1066 void HeroClass::setClimbCoverX(int32_t new_x)
1067 {
1068 climb_cover_x=new_x;
1069 }
1070 void HeroClass::setClimbCoverY(int32_t new_y)
1071 {
1072 climb_cover_y=new_y;
1073 }
1074 25643 int32_t HeroClass::getLStep()
1075 {
1076 25643 return lstep;
1077 }
1078 1318 int32_t HeroClass::getCharging()
1079 {
1080 1318 return charging;
1081 }
1082 17964 bool HeroClass::isCharged()
1083 {
1084 17964 return spins>0;
1085 }
1086 int32_t HeroClass::getAttackClk()
1087 {
1088 return attackclk;
1089 }
1090 void HeroClass::setAttackClk(int32_t new_clk)
1091 {
1092 attackclk=new_clk;
1093 }
1094 void HeroClass::setCharging(int32_t new_charging)
1095 {
1096 charging=new_charging;
1097 }
1098 808915420 int32_t HeroClass::getSwordClk()
1099 {
1100 808915420 return swordclk;
1101 }
1102 789024329 int32_t HeroClass::getItemClk()
1103 {
1104 789024329 return itemclk;
1105 }
1106 void HeroClass::setSwordClk(int32_t newclk)
1107 {
1108 swordclk=newclk;
1109 verifyAWpn();
1110 }
1111 void HeroClass::setItemClk(int32_t newclk)
1112 {
1113 itemclk=newclk;
1114 }
1115 51432 zfix HeroClass::getModifiedX()
1116 {
1117 51432 zfix tempx=x;
1118
1119
4/4
✓ Branch 0 taken 10991 times.
✓ Branch 1 taken 40441 times.
✓ Branch 2 taken 9126 times.
✓ Branch 3 taken 1865 times.
51432 if(screenscrolling&&(dir==left))
1120 {
1121 1865 tempx=tempx+256;
1122 1865 }
1123
1124 51432 return tempx;
1125 }
1126
1127 51432 zfix HeroClass::getModifiedY()
1128 {
1129 51432 zfix tempy=y;
1130
1131
4/4
✓ Branch 0 taken 10991 times.
✓ Branch 1 taken 40441 times.
✓ Branch 2 taken 3845 times.
✓ Branch 3 taken 7146 times.
51432 if(screenscrolling&&(dir==up))
1132 {
1133 3845 tempy=tempy+176;
1134 3845 }
1135
1136 51432 return tempy;
1137 }
1138
1139 3862 int32_t HeroClass::getDir()
1140 {
1141 3862 return dir;
1142 }
1143 181 void HeroClass::setDir(int32_t newdir)
1144 {
1145 181 dir=newdir;
1146 181 reset_hookshot();
1147 181 }
1148 int32_t HeroClass::getHitDir()
1149 {
1150 return hitdir;
1151 }
1152 void HeroClass::setHitDir(int32_t newdir)
1153 {
1154 hitdir = newdir;
1155 }
1156 int32_t HeroClass::getClk()
1157 {
1158 return clk;
1159 }
1160 int32_t HeroClass::getPushing()
1161 {
1162 return pushing;
1163 }
1164 3539 void HeroClass::Catch()
1165 {
1166
5/6
✓ Branch 0 taken 3539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✓ Branch 3 taken 774 times.
✓ Branch 4 taken 1435 times.
✓ Branch 5 taken 1330 times.
3539 if(!inwallm && (action==none || action==walking))
1167 {
1168 2209 SetAttack();
1169 2209 attackclk=0;
1170 2209 attack=wCatching;
1171 2209 }
1172 3539 }
1173
1174 1469442 bool HeroClass::getClock()
1175 {
1176 1469442 return superman;
1177 }
1178 306 void HeroClass::setClock(bool state)
1179 {
1180 306 superman=state;
1181 306 }
1182 13040800 int32_t HeroClass::getAction() // Used by ZScript
1183 {
1184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13040800 times.
13040800 if(spins > 0)
1185 return isspinning;
1186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13040800 times.
13040800 else if(charging > 0)
1187 return ischarging;
1188
2/2
✓ Branch 0 taken 13027528 times.
✓ Branch 1 taken 13272 times.
13040800 else if(diveclk > 0)
1189 13272 return isdiving;
1190 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1191
1192 13027528 return action;
1193 13040800 }
1194
1195 3738025 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1196 {
1197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3738025 times.
3738025 if(spins > 0)
1198 return isspinning;
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3738025 times.
3738025 else if(charging > 0)
1200 return ischarging;
1201
2/2
✓ Branch 0 taken 3726975 times.
✓ Branch 1 taken 11050 times.
3738025 else if(diveclk > 0)
1202 11050 return isdiving;
1203 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1204
1205 3726975 return -1;
1206 3738025 }
1207
1208 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1209 {
1210 if(new_action==dying || new_action==won || new_action==scrolling ||
1211 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1212 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1213 return; // Can't use these actions.
1214
1215 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1216 return;
1217
1218 if(new_action==rafting)
1219 {
1220 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1221 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1222 return;
1223 }
1224
1225
1226 if(magicitem>-1 && itemsbuf[magicitem].family==itype_faroreswind)
1227 {
1228 // Using Farore's Wind
1229 if(magiccastclk<96)
1230 {
1231 // Not cast yet; cancel it
1232 magicitem=-1;
1233 magiccastclk=0;
1234 }
1235 else
1236 // Already activated; don't do anything
1237 return;
1238 }
1239
1240 if(action==inwind) // Remove from whirlwind
1241 {
1242 xofs=0;
1243 whirlwind=0;
1244 lstep=0;
1245 if ( dontdraw < 2 ) { dontdraw=0; }
1246 }
1247 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1248 {
1249 sprite* wind=0;
1250 bool foundWind=false;
1251 for(int32_t i=0; i<Ewpns.Count(); i++)
1252 {
1253 wind=Ewpns.spr(i);
1254 if(wind->id==ewWind && wind->misc==999)
1255 {
1256 foundWind=true;
1257 break;
1258 }
1259 }
1260
1261 if(foundWind)
1262 {
1263 xofs=0;
1264 if ( dontdraw < 2 ) { dontdraw=false; }
1265 wind->misc=-1;
1266 x=wind->x;
1267 y=wind->y;
1268 }
1269 }
1270
1271 //Unless compat rule is on, reset hopping clocks when writing action!
1272 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1273 {
1274 hopclk = 0;
1275 hopdir = -1;
1276 }
1277
1278 if(new_action != attacking && new_action != sideswimattacking)
1279 {
1280 attackclk=0;
1281
1282 if(attack==wHookshot)
1283 reset_hookshot();
1284 }
1285 if(new_action != isspinning && new_action != sideswimisspinning)
1286 {
1287 charging = 0;
1288 spins = 0;
1289 }
1290
1291 if(action == falling && new_action != falling)
1292 {
1293 fallclk = 0; //Stop falling;
1294 }
1295
1296 if (action == rafting && new_action != rafting)
1297 {
1298 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1299 raftwarpy = y;
1300 }
1301
1302 switch(new_action)
1303 {
1304 case isspinning:
1305 case sideswimisspinning:
1306 if(attack==wSword)
1307 {
1308 attackclk = SWORDCHARGEFRAME+1;
1309 charging = 0;
1310
1311 if(spins==0)
1312 spins = 5;
1313 }
1314 return;
1315
1316 case isdiving:
1317 if(action==swimming && diveclk==0)
1318 {
1319 int32_t flippers_id = current_item_id(itype_flippers);
1320 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1321 }
1322 return;
1323
1324 case drowning:
1325 case sidedrowning:
1326 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1327 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1328 if(!drownclk)
1329 Drown();
1330
1331 break;
1332
1333 case lavadrowning:
1334 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1335 if(!drownclk)
1336 Drown(1);
1337
1338 break;
1339
1340 case falling:
1341 if(!fallclk)
1342 {
1343 //If there is a pit under Hero, use it's combo.
1344 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1345 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1346 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1347 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1348 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1349 //Else, use a null value; triggers default pit values
1350 else fallCombo = 0;
1351 fallclk = PITFALL_FALL_FRAMES;
1352 }
1353 break;
1354
1355 case gothit:
1356 case swimhit:
1357 case sideswimhit:
1358 if(!hclk)
1359 hclk=48;
1360
1361 break;
1362
1363 case landhold1:
1364 case landhold2:
1365 case waterhold1:
1366 case waterhold2:
1367 case sidewaterhold1:
1368 case sidewaterhold2:
1369 if(!holdclk)
1370 holdclk=130;
1371
1372 attack=none;
1373 break;
1374
1375 case attacking:
1376 case sideswimattacking:
1377 attack=none;
1378 break;
1379
1380 default:
1381 break;
1382 }
1383
1384 action=new_action; FFCore.setHeroAction(new_action);
1385 }
1386
1387 void HeroClass::setHeldItem(int32_t newitem)
1388 {
1389 holditem=newitem;
1390 }
1391 int32_t HeroClass::getHeldItem()
1392 {
1393 return holditem;
1394 }
1395 1884847 bool HeroClass::isDiving()
1396 {
1397 1884847 int32_t flippers_id = current_item_id(itype_flippers);
1398
2/2
✓ Branch 0 taken 1755597 times.
✓ Branch 1 taken 129250 times.
1884847 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1399 }
1400 4243308 bool HeroClass::isSwimming()
1401 {
1402
4/6
✓ Branch 0 taken 4226092 times.
✓ Branch 1 taken 17216 times.
✓ Branch 2 taken 4226092 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4226092 times.
✗ Branch 5 not taken.
8469400 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1403
3/4
✓ Branch 0 taken 4225572 times.
✓ Branch 1 taken 520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4225572 times.
4226092 (action==waterhold1)||(action==waterhold2)||
1404 4225572 (hopclk==0xFF));
1405 }
1406
1407 337 void HeroClass::setDontDraw(byte new_dontdraw)
1408 {
1409 337 dontdraw=new_dontdraw;
1410 337 }
1411
1412 182004 byte HeroClass::getDontDraw()
1413 {
1414 182004 return dontdraw;
1415 }
1416
1417 void HeroClass::setHClk(int32_t newhclk)
1418 {
1419 hclk=newhclk;
1420 }
1421
1422 27969 int32_t HeroClass::getHClk()
1423 {
1424 27969 return hclk;
1425 }
1426
1427 562922 int32_t HeroClass::getSpecialCave()
1428 {
1429 562922 return specialcave; // used only by maps.cpp
1430 }
1431
1432 97 void HeroClass::init()
1433 {
1434 97 usecounts.clear();
1435 97 scale = 0;
1436 97 rotation = 0;
1437 97 do_animation = 1;
1438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(lift_wpn)
1439 {
1440 delete lift_wpn;
1441 lift_wpn = nullptr;
1442 }
1443 97 liftclk = 0;
1444 97 tliftclk = 0;
1445 97 liftheight = 0;
1446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1447 97 hookshot_used=false;
1448 97 hookshot_frozen=false;
1449 97 onpassivedmg=false;
1450 97 dir = up;
1451 97 damageovertimeclk = 0;
1452 97 newconveyorclk = 0;
1453 97 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1454
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 97 times.
776 for(auto q = 0; q < 7; ++q)
1455 679 hooked_undercombos[q] = -1;
1456 97 shiftdir = -1;
1457 97 sideswimdir = right;
1458 97 holddir = -1;
1459 97 landswim = 0;
1460 97 sdir = up;
1461 97 ilswim=true;
1462 97 walkable=false;
1463 97 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1464 97 warp_sound = 0;
1465 97 subscr_speed = zinit.subscrSpeed;
1466 97 steprate = zinit.heroStep;
1467 97 is_warping = false;
1468 97 can_mirror_portal = true;
1469
1470 97 hammer_swim_up_offset = hammeroffsets[0];
1471 97 hammer_swim_down_offset = hammeroffsets[1];
1472 97 hammer_swim_left_offset = hammeroffsets[2];
1473 97 hammer_swim_right_offset = hammeroffsets[3];
1474
1475 97 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1476
1477
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 95 times.
97 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1478 {
1479 2 x=tmpscr->warpreturnx[0];
1480 2 y=tmpscr->warpreturny[0];
1481 2 }
1482 else
1483 {
1484 95 x=tmpscr->warparrivalx;
1485 95 y=tmpscr->warparrivaly;
1486 }
1487
1488 97 z=fakez=fall=fakefall=0;
1489 97 hzsz = 12; // So that flying peahats can still hit him.
1490
1491
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 82 times.
97 if(x==0) dir=right;
1492
1493
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 96 times.
97 if(x==240) dir=left;
1494
1495
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 if(y==0) dir=down;
1496
1497
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 82 times.
97 if(y==160) dir=up;
1498
1499 97 lstep=0;
1500 97 skipstep=0;
1501 97 autostep=false;
1502 97 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1503 97 attack=wNone;
1504 97 attackid=-1;
1505 97 action=none; FFCore.setHeroAction(none); tempaction=none;
1506 97 xofs=0;
1507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1508 97 cs=6;
1509 97 pushing=fairyclk=0;
1510 97 id=0;
1511 97 inlikelike=0;
1512 97 superman=inwallm=false;
1513 97 scriptcoldet=1;
1514 97 blowcnt=whirlwind=specialcave=0;
1515 97 hopclk=diveclk=fallclk=0;
1516 97 fallCombo = 0;
1517 97 pit_pulldir = -1;
1518 97 hopdir=-1;
1519 97 conveyor_flags=0;
1520 97 drunkclk=0;
1521 97 lstunclock = 0;
1522 97 is_conveyor_stunned=0;
1523 97 drawstyle=3;
1524 97 ffwarp = false;
1525 97 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1526 97 stepnext=stepsecret=-1;
1527 97 ffpit = false;
1528 97 respawn_x=x;
1529 97 respawn_y=y;
1530 97 respawn_dmap=currdmap;
1531 97 respawn_scr=currscr;
1532 97 falling_oldy = y;
1533 97 magiccastclk=0;
1534 97 magicitem = nayruitem = -1;
1535 97 last_lens_id = 0; //Should be -1 (-Z)
1536 97 last_savepoint_id = 0;
1537 97 misc_internal_hero_flags = 0;
1538 97 last_cane_of_byrna_item_id = -1;
1539 97 on_sideview_ladder = false;
1540 97 switchblock_z = 0;
1541 97 switchblock_offset = false;
1542 97 extra_jump_count = 0;
1543 97 hoverflags = 0;
1544 97 lbunnyclock = 0;
1545
1546
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 97 times.
3201 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1547
1548 97 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1549 97 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1550
1551 97 shield_active = false;
1552 97 shield_forcedir = -1;
1553 97 active_shield_id = -1;
1554
1555 //2.6
1556 97 preventsubscreenfalling = false; //-Z
1557 97 walkspeed = 0; //not used, yet. -Z
1558
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 97 times.
1649 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1559
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 97 times.
1649 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1560
2/2
✓ Branch 0 taken 14162 times.
✓ Branch 1 taken 97 times.
14259 for ( int32_t q = 0; q < wMax; q++ )
1561 {
1562 14162 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1563 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1564 14162 }
1565 //Run script!
1566
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
97 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1567 {
1568 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1569 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1570 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1571 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1572 //are properly set by the engine.
1573 }
1574 97 FFCore.nostepforward = 0;
1575 97 }
1576
1577 2242668 void HeroClass::draw_under(BITMAP* dest)
1578 {
1579 2242668 int32_t c_raft=current_item_id(itype_raft);
1580 2242668 int32_t c_ladder=current_item_id(itype_ladder);
1581
1582
3/4
✓ Branch 0 taken 8721 times.
✓ Branch 1 taken 2233947 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8721 times.
2242668 if(action==rafting && c_raft >-1)
1583 {
1584
4/4
✓ Branch 0 taken 7167 times.
✓ Branch 1 taken 1554 times.
✓ Branch 2 taken 8042 times.
✓ Branch 3 taken 679 times.
8721 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1585 {
1586 1358 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1587 679 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1588 679 }
1589 else
1590 {
1591 16084 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1592 8042 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1593 }
1594 8721 }
1595
1596
3/4
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 2203756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
2242668 if(ladderx+laddery && c_ladder >-1)
1597 {
1598
4/4
✓ Branch 0 taken 19239 times.
✓ Branch 1 taken 19673 times.
✓ Branch 2 taken 3128 times.
✓ Branch 3 taken 16111 times.
38912 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1599 {
1600 6256 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1601 3128 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1602 3128 }
1603 else
1604 {
1605 71568 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1606 35784 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1607 }
1608 38912 }
1609 2242668 }
1610
1611 120 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1612 {
1613 120 int32_t tempy=yofs;
1614 120 yofs+=8;
1615 120 shadowtile = wpnsbuf[spr_shadow].tile;
1616 120 sprite::drawshadow(dest,translucent);
1617 120 yofs=tempy;
1618 120 }
1619
1620 // The Stone of Agony reacts to these flags.
1621 bool HeroClass::agonyflag(int32_t flag)
1622 {
1623 switch(flag)
1624 {
1625 case mfWHISTLE:
1626 case mfBCANDLE:
1627 case mfARROW:
1628 case mfBOMB:
1629 case mfSBOMB:
1630 case mfBRANG:
1631 case mfMBRANG:
1632 case mfFBRANG:
1633 case mfSARROW:
1634 case mfGARROW:
1635 case mfRCANDLE:
1636 case mfWANDFIRE:
1637 case mfDINSFIRE:
1638 case mfWANDMAGIC:
1639 case mfREFMAGIC:
1640 case mfREFFIREBALL:
1641 case mfSWORD:
1642 case mfWSWORD:
1643 case mfMSWORD:
1644 case mfXSWORD:
1645 case mfSWORDBEAM:
1646 case mfWSWORDBEAM:
1647 case mfMSWORDBEAM:
1648 case mfXSWORDBEAM:
1649 case mfHOOKSHOT:
1650 case mfWAND:
1651 case mfHAMMER:
1652 case mfSTRIKE:
1653 return true;
1654 }
1655
1656 return false;
1657 }
1658
1659
1660 // Find the attack power of the current melee weapon.
1661 // The Whimsical Ring is applied on a target-by-target basis.
1662 191494 int32_t HeroClass::weaponattackpower(int32_t itid)
1663 {
1664
1/2
✓ Branch 0 taken 191494 times.
✗ Branch 1 not taken.
191494 if(itid < 0)
1665 {
1666 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1667 : attack==wWand ? itype_wand
1668 : attack==wHammer ? itype_hammer
1669 : itype_sword);
1670 }
1671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191494 times.
191494 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1672
1673 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1674
1/6
✓ Branch 0 taken 191494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
191494 power *= (spins>0 ? itemsbuf[current_item_id(attack==wHammer ? itype_quakescroll : (spins>5 || current_item_id(itype_spinscroll) < 0) ? itype_spinscroll2 : itype_spinscroll)].power : 1);
1675 191494 return power;
1676 }
1677
1678 #define NET_CLK_TOTAL 24
1679 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1680 // Must only be called once per frame!
1681 void HeroClass::positionNet(weapon *w, int32_t itemid)
1682 {
1683 itemid = vbound(itemid, 0, MAXITEMS-1);
1684 int32_t t = w->o_tile,
1685 wx = 1, wy = 1;
1686
1687 //Invert positioning clock if right-handed animation
1688 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1689 if(clock >= NET_CLK_TOTAL)
1690 w->dead = 0;
1691 int32_t tiledir = dir;
1692 switch(dir)
1693 {
1694 case up:
1695 {
1696 if(clock < NET_DIR_INC) tiledir = l_up;
1697 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1698 break;
1699 }
1700 case down:
1701 {
1702 if(clock < NET_DIR_INC) tiledir = r_down;
1703 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1704 break;
1705 }
1706 case left:
1707 {
1708 if(clock < NET_DIR_INC) tiledir = l_down;
1709 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1710 break;
1711 }
1712 case right:
1713 {
1714 if(clock < NET_DIR_INC) tiledir = r_up;
1715 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1716 break;
1717 }
1718 }
1719 int32_t offs = 0;
1720 if(tiledir > right)
1721 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1722 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1723 //One of 8 positions
1724 switch(tiledir)
1725 {
1726 case up:
1727 {
1728 wx = 6*offs;
1729 wy = -14;
1730 break;
1731 }
1732 case r_up:
1733 {
1734 wx = (offs ? 10 : 14);
1735 wy = (offs ? -12 : -10);
1736 break;
1737 }
1738 case right:
1739 {
1740 wx = 14;
1741 wy = 6*offs;
1742 break;
1743 }
1744 case r_down:
1745 {
1746 wx = (offs ? 14 : 10);
1747 wy = (offs ? 10 : 12);
1748 break;
1749 }
1750 case down:
1751 {
1752 wx = -6*offs;
1753 wy = 14;
1754 break;
1755 }
1756 case l_down:
1757 {
1758 wx = (offs ? -10 : -14);
1759 wy = (offs ? 12 : 10);
1760 break;
1761 }
1762 case left:
1763 {
1764 wx = -14;
1765 wy = -6*offs;
1766 break;
1767 }
1768 case l_up:
1769 {
1770 wx = (offs ? -14 : -10);
1771 wy = (offs ? -10 : -12);
1772 break;
1773 }
1774 }
1775
1776 w->x = x+wx;
1777 w->y = y+wy-(54-(yofs))-fakez;
1778 w->z = (z+zofs);
1779 w->fakez = fakez;
1780 w->tile = t+tiledir;
1781 w->power = 0;
1782 w->dir = dir;
1783 w->doAutoRotate(true);
1784 }
1785 176722 void HeroClass::positionSword(weapon *w, int32_t itemid)
1786 {
1787 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1788 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1789 176722 itemid=vbound(itemid, 0, MAXITEMS-1);
1790 // Place a sword weapon at the right spot.
1791 176722 int32_t wy=1;
1792 176722 int32_t wx=1;
1793 176722 int32_t f=0,t,cs2;
1794
1795 176722 t = w->o_tile;
1796 176722 cs2 = w->o_cset;
1797 176722 slashxofs=0;
1798 176722 slashyofs=0;
1799
1800
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39008 times.
✓ Branch 2 taken 36462 times.
✓ Branch 3 taken 50537 times.
✓ Branch 4 taken 50715 times.
176722 switch(dir)
1801 {
1802 case up:
1803 39008 wx=-1;
1804 39008 wy=-12;
1805
1806
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 39008 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
39008 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1807 {
1808 if(attackclk>10) //extended stab
1809 {
1810 slashyofs-=3;
1811 wy-=2;
1812 }
1813
1814 if(attackclk>=14) //retracting stab
1815 {
1816 slashyofs+=3;
1817 wy+=2;
1818 }
1819 }
1820 else
1821 {
1822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39008 times.
39008 if(attackclk==SWORDCHARGEFRAME)
1823 {
1824 wy+=4;
1825 }
1826
2/2
✓ Branch 0 taken 3811 times.
✓ Branch 1 taken 35197 times.
39008 else if(attackclk==13)
1827 {
1828 3811 wy+=4;
1829 3811 }
1830
2/2
✓ Branch 0 taken 31399 times.
✓ Branch 1 taken 3798 times.
35197 else if(attackclk==14)
1831 {
1832 3798 wy+=8;
1833 3798 }
1834 }
1835
1836 39008 break;
1837
1838 case down:
1839 36462 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1840 36462 wy=11;
1841
1842
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 36462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36462 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1843 {
1844 if(attackclk>10) //extended stab
1845 {
1846 slashyofs+=3;
1847 wy+=2;
1848 }
1849
1850 if(attackclk>=14) //retracting stab
1851 {
1852 slashyofs-=3;
1853 wy-=2;
1854 }
1855 }
1856 else
1857 {
1858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36462 times.
36462 if(attackclk==SWORDCHARGEFRAME)
1859 {
1860 wy-=2;
1861 }
1862
2/2
✓ Branch 0 taken 3628 times.
✓ Branch 1 taken 32834 times.
36462 else if(attackclk==13)
1863 {
1864 3628 wy-=4;
1865 3628 }
1866
2/2
✓ Branch 0 taken 29215 times.
✓ Branch 1 taken 3619 times.
32834 else if(attackclk==14)
1867 {
1868 3619 wy-=8;
1869 3619 }
1870 }
1871
1872 36462 break;
1873
1874 case left:
1875 50537 f=1;
1876 50537 wx=-11;
1877 50537 ++t;
1878
1879
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 50537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50537 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1880 {
1881 if(attackclk>10) //extended stab
1882 {
1883 slashxofs-=4;
1884 wx-=7;
1885 }
1886
1887 if(attackclk>=14) //retracting stab
1888 {
1889 slashxofs+=3;
1890 wx+=7;
1891 }
1892 }
1893 else
1894 {
1895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50537 times.
50537 if(attackclk==SWORDCHARGEFRAME)
1896 {
1897 wx+=2;
1898 }
1899
2/2
✓ Branch 0 taken 5043 times.
✓ Branch 1 taken 45494 times.
50537 else if(attackclk==13)
1900 {
1901 5043 wx+=4;
1902 5043 }
1903
2/2
✓ Branch 0 taken 40466 times.
✓ Branch 1 taken 5028 times.
45494 else if(attackclk==14)
1904 {
1905 5028 wx+=8;
1906 5028 }
1907 }
1908
1909 50537 break;
1910
1911 case right:
1912 50715 wx=11;
1913 50715 ++t;
1914
1915
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 50715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50715 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1916 {
1917 if(attackclk>10) //extended stab
1918 {
1919 slashxofs+=4;
1920 wx+=7;
1921 }
1922
1923 if(attackclk>=14) //retracting stab
1924 {
1925 slashxofs-=3;
1926 wx-=7;
1927 }
1928 }
1929 else
1930 {
1931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50715 times.
50715 if(attackclk==SWORDCHARGEFRAME)
1932 {
1933 wx-=2;
1934 }
1935
2/2
✓ Branch 0 taken 5027 times.
✓ Branch 1 taken 45688 times.
50715 else if(attackclk==13)
1936 {
1937 5027 wx-=4;
1938 5027 }
1939
2/2
✓ Branch 0 taken 40670 times.
✓ Branch 1 taken 5018 times.
45688 else if(attackclk==14)
1940 {
1941 5018 wx-=8;
1942 5018 }
1943 }
1944
1945 50715 break;
1946 }
1947
1948
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 176722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
176722 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1949 {
1950 int32_t wpn2=itemsbuf[itemid].wpn2;
1951 wpn2=vbound(wpn2, 0, MAXWPNS);
1952
1953 //slashing tiles
1954 switch(dir)
1955 {
1956 case up:
1957 wx=15;
1958 wy=-3;
1959 ++t;
1960 f=0; //starts pointing right
1961
1962 if(attackclk>=7)
1963 {
1964 wy-=9;
1965 wx-=3;
1966 t = wpnsbuf[wpn2].tile;
1967 cs2 = wpnsbuf[wpn2].csets&15;
1968 f=0;
1969 }
1970
1971 break;
1972
1973 case down:
1974 wx=-13;
1975 wy=-1;
1976 ++t;
1977 f=1; //starts pointing left
1978
1979 if(attackclk>=7)
1980 {
1981 wy+=15;
1982 wx+=2;
1983 t = wpnsbuf[wpn2].tile;
1984 cs2 = wpnsbuf[wpn2].csets&15;
1985 ++t;
1986 f=0;
1987 }
1988
1989 break;
1990
1991 case left:
1992 wx=3;
1993 wy=-15;
1994 --t;
1995 f=0; //starts pointing up
1996
1997 if(attackclk>=7)
1998 {
1999 wx-=15;
2000 wy+=3;
2001 slashxofs-=1;
2002 t = wpnsbuf[wpn2].tile;
2003 cs2 = wpnsbuf[wpn2].csets&15;
2004 t+=2;
2005 f=0;
2006 }
2007
2008 break;
2009
2010 case right:
2011 --t;
2012
2013 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2014 {
2015 wx=1;
2016 wy=13;
2017 f=2;
2018 }
2019 else
2020 {
2021 wx=3;
2022 wy=-15;
2023 f=0;
2024 }
2025
2026 if(attackclk>=7)
2027 {
2028 wx+=15;
2029 slashxofs+=1;
2030 t = wpnsbuf[wpn2].tile;
2031 cs2 = wpnsbuf[wpn2].csets&15;
2032
2033 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2034 {
2035 wx-=1;
2036 wy-=2;
2037 }
2038 else
2039 {
2040 t+=3;
2041 f=0;
2042 wy+=3;
2043 }
2044 }
2045
2046 break;
2047 }
2048 }
2049
2050 176722 int32_t itemid2 = current_item_id(itype_chargering);
2051
2052
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 176722 times.
✓ Branch 2 taken 176722 times.
✗ Branch 3 not taken.
176722 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2053 {
2054 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2055 }
2056
2057 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2058 {
2059 wy+=2;
2060 }*/
2061 176722 w->x = x+wx;
2062 176722 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2063 176722 w->z = (z+zofs);
2064 176722 w->tile = t;
2065 176722 w->flip = f;
2066 176722 w->power = weaponattackpower(itemid);
2067 176722 w->dir = dir;
2068 176722 w->doAutoRotate(true);
2069 176722 }
2070
2071 2255360 void HeroClass::draw(BITMAP* dest)
2072 {
2073 /*{
2074 char buf[36];
2075 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2076 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2077 }*/
2078 int32_t oxofs, oyofs;
2079 2255360 bool shieldModify = false;
2080
2/2
✓ Branch 0 taken 2246991 times.
✓ Branch 1 taken 8369 times.
2255360 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2081
2082
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 2254940 times.
2255360 if(action==dying)
2083 {
2084
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 98 times.
420 if(!invisible)
2085 {
2086
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2087 98 sprite::draw(dest);
2088 98 }
2089 420 return;
2090 }
2091
2092 2254940 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2093
2094 2254940 oxofs=xofs;
2095 2254940 oyofs=yofs;
2096
2097
2/2
✓ Branch 0 taken 8047 times.
✓ Branch 1 taken 2246893 times.
2254940 if(!invisible)
2098
6/6
✓ Branch 0 taken 2236176 times.
✓ Branch 1 taken 10717 times.
✓ Branch 2 taken 1670248 times.
✓ Branch 3 taken 565928 times.
✓ Branch 4 taken 96574 times.
✓ Branch 5 taken 1573674 times.
2246893 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2099
2100 // Stone of Agony
2101 2254940 bool agony=false;
2102 2254940 int32_t agonyid = current_item_id(itype_agony);
2103
2104
2/2
✓ Branch 0 taken 8047 times.
✓ Branch 1 taken 2246893 times.
2254940 if(invisible)
2105 8047 goto attack;
2106
2107
1/2
✓ Branch 0 taken 2246893 times.
✗ Branch 1 not taken.
2246893 if(agonyid>-1)
2108 {
2109 int32_t power=itemsbuf[agonyid].power;
2110 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2111 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2112 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2113 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2114
2115 for(int32_t x=left; x<right; x+=16)
2116 {
2117 for(int32_t y=top; y<bottom; y+=16)
2118 {
2119 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2120 {
2121 agony=true;
2122 x=right; // Break out of outer loop
2123 break;
2124 }
2125 }
2126 }
2127 }
2128
2129 2246893 cs = 6;
2130
1/2
✓ Branch 0 taken 2246893 times.
✗ Branch 1 not taken.
2246893 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2131
2/2
✓ Branch 0 taken 439144 times.
✓ Branch 1 taken 1807749 times.
4054642 if(!get_bit(quest_rules,qr_HEROFLICKER))
2132 {
2133
3/4
✓ Branch 0 taken 45117 times.
✓ Branch 1 taken 1762632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45117 times.
1807749 if(superman && getCanFlicker())
2134 {
2135 45117 cs += (((~frame)>>1)&3);
2136 45117 }
2137
4/6
✓ Branch 0 taken 85181 times.
✓ Branch 1 taken 1677451 times.
✓ Branch 2 taken 85181 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85181 times.
1762632 else if(hclk&&(NayrusLoveShieldClk<=0) && getCanFlicker())
2138 {
2139 85181 cs += ((hclk>>1)&3);
2140 85181 }
2141 1807749 }
2142
2143 attack:
2144
2145
5/6
✓ Branch 0 taken 1939123 times.
✓ Branch 1 taken 315817 times.
✓ Branch 2 taken 1936914 times.
✓ Branch 3 taken 2209 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1936914 times.
2254940 if(attackclk || (action==attacking||action==sideswimattacking))
2146 {
2147 /* Spaghetti code constants!
2148 * - Hero.attack contains a weapon type...
2149 * - which must be converted to an itype...
2150 * - which must be converted to an item ID...
2151 * - which is used to acquire a wpn ID! Aack!
2152 */
2153
6/8
✓ Branch 0 taken 2421 times.
✓ Branch 1 taken 315605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315605 times.
✓ Branch 4 taken 4326 times.
✓ Branch 5 taken 311279 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 311279 times.
318026 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 318026 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
318026 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2155 318026 itemid=vbound(itemid, 0, MAXITEMS-1);
2156 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2157
6/8
✓ Branch 0 taken 101516 times.
✓ Branch 1 taken 216510 times.
✓ Branch 2 taken 101516 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71487 times.
✓ Branch 5 taken 30029 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 71487 times.
318026 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2158 {
2159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216510 times.
216510 if(attack == wBugNet)
2160 {
2161 weapon *w=NULL;
2162 bool found = false;
2163 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2164 {
2165 w = (weapon*)Lwpns.spr(q);
2166 if(w->id == wBugNet)
2167 {
2168 found = true;
2169 break;
2170 }
2171 }
2172 if(!found)
2173 {
2174 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2175
2176 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2177 }
2178 positionNet(w, itemid);
2179 }
2180
8/8
✓ Branch 0 taken 42877 times.
✓ Branch 1 taken 173633 times.
✓ Branch 2 taken 39787 times.
✓ Branch 3 taken 3090 times.
✓ Branch 4 taken 38106 times.
✓ Branch 5 taken 1681 times.
✓ Branch 6 taken 39787 times.
✓ Branch 7 taken 176723 times.
216510 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2181 {
2182 // Create a sword weapon at the right spot.
2183 176723 weapon *w=NULL;
2184 176723 bool found = false;
2185
2186 // Look for pre-existing sword
2187
2/2
✓ Branch 0 taken 17965 times.
✓ Branch 1 taken 191949 times.
209914 for(int32_t i=0; i<Lwpns.Count(); i++)
2188 {
2189 191949 w = (weapon*)Lwpns.spr(i);
2190
2191
2/2
✓ Branch 0 taken 33191 times.
✓ Branch 1 taken 158758 times.
191949 if(w->id == (attack==wSword ? wSword : wWand))
2192 {
2193 158758 found = true;
2194 158758 break;
2195 }
2196 33191 }
2197
2198
2/2
✓ Branch 0 taken 158758 times.
✓ Branch 1 taken 17965 times.
176723 if(!found) // Create one if sword nonexistant
2199 {
2200
5/10
✓ Branch 0 taken 17965 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17965 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17965 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 17965 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17965 times.
✗ Branch 9 not taken.
17965 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2201 17965 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2202
2203 17965 positionSword(w,itemid);
2204
2205 // Stone of Agony
2206
1/2
✓ Branch 0 taken 17965 times.
✗ Branch 1 not taken.
17965 if(agony)
2207 {
2208 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2209 }
2210 17965 }
2211
2212 // These are set by positionSword(), above or in checkstab()
2213 176723 yofs += slashyofs;
2214 176723 xofs += slashxofs;
2215 176723 slashyofs = slashxofs = 0;
2216 176723 }
2217 216510 }
2218
2219 318026 if(attackclk<7
2220
4/4
✓ Branch 0 taken 169152 times.
✓ Branch 1 taken 148874 times.
✓ Branch 2 taken 138491 times.
✓ Branch 3 taken 30661 times.
318026 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2221
4/6
✓ Branch 0 taken 34354 times.
✓ Branch 1 taken 104137 times.
✓ Branch 2 taken 34354 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34354 times.
138491 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34354 times.
34354 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2223
4/4
✓ Branch 0 taken 62543 times.
✓ Branch 1 taken 2472 times.
✓ Branch 2 taken 61232 times.
✓ Branch 3 taken 1311 times.
65015 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2224
3/4
✓ Branch 0 taken 2862 times.
✓ Branch 1 taken 62153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62153 times.
65015 || (attack==wHammer && attackclk<=30)
2225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62153 times.
62153 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2226 {
2227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255873 times.
255873 if(!invisible)
2228 {
2229 255873 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2230
2/4
✓ Branch 0 taken 255873 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 255873 times.
✗ Branch 3 not taken.
255873 if (FIXED_Z3_ANIMATION)
2231 {
2232 if (attackclk >= 2) tile += (extend==2?2:1);
2233 if (attackclk >= 13) tile += (extend==2?2:1);
2234 }
2235
2236
1/18
✗ Branch 0 not taken.
✓ Branch 1 taken 255873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
255873 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2237 {
2238 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2239 if (FIXED_Z3_ANIMATION)
2240 {
2241 if (attackclk >= 7) tile += (extend==2?2:1);
2242 if (attackclk >= 11) tile += (extend==2?2:1);
2243 if (attackclk >= 14) tile += (extend==2?2:1);
2244 }
2245 }
2246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 255873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
255873 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2247 {
2248 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2249 {
2250 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2251 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2252 }
2253 else
2254 {
2255 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2256 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2257 }
2258 }
2259
2260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 255873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
255873 if((attack==wHammer) && (attackclk<13))
2261 {
2262 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2263 if (FIXED_Z3_ANIMATION)
2264 {
2265 if (attackclk >= 14) tile += (extend==2?2:1);
2266 if (attackclk >= 16) tile += (extend==2?2:1);
2267 }
2268 }
2269
2270
1/2
✓ Branch 0 taken 255873 times.
✗ Branch 1 not taken.
255873 if(useltm)
2271 {
2272 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2273 }
2274
2275 // Stone of Agony
2276
1/2
✓ Branch 0 taken 255873 times.
✗ Branch 1 not taken.
255873 if(agony)
2277 {
2278 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2279 }
2280
2281 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2282
2283 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2284
6/6
✓ Branch 0 taken 46820 times.
✓ Branch 1 taken 209053 times.
✓ Branch 2 taken 45568 times.
✓ Branch 3 taken 1252 times.
✓ Branch 4 taken 2802 times.
✓ Branch 5 taken 44018 times.
255873 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2285 {
2286 253071 masked_draw(dest);
2287 253071 }
2288
2289 //Prevent flickering -Z
2290
1/2
✓ Branch 0 taken 255873 times.
✗ Branch 1 not taken.
255873 if (!getCanFlicker()) masked_draw(dest);
2291 255873 }
2292
2293
1/2
✓ Branch 0 taken 255873 times.
✗ Branch 1 not taken.
255873 if(attack!=wHammer)
2294 {
2295 255873 xofs=oxofs;
2296 255873 yofs=oyofs;
2297 255873 return;
2298 }
2299 }
2300
2301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62153 times.
62153 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2302 {
2303 int32_t wy=1;
2304 int32_t wx=1;
2305 int32_t f=0,t,cs2;
2306 weapon *w=NULL;
2307 bool found = false;
2308
2309 for(int32_t i=0; i<Lwpns.Count(); i++)
2310 {
2311 w = (weapon*)Lwpns.spr(i);
2312
2313 if(w->id == wHammer)
2314 {
2315 found = true;
2316 break;
2317 }
2318 }
2319
2320 if(!found)
2321 {
2322 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2323 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2324 found = true;
2325 }
2326
2327 t = w->o_tile;
2328 cs2 = w->o_cset;
2329
2330 switch(dir)
2331 {
2332 case up:
2333 wx=-1;
2334 wy=-15;
2335 if (IsSideSwim())wy+=hammer_swim_up_offset;
2336
2337 if(attackclk>=13)
2338 {
2339 wx-=1;
2340 wy+=1;
2341 ++t;
2342 }
2343
2344 if(attackclk>=15)
2345 {
2346 if (IsSideSwim())wy-=hammer_swim_up_offset;
2347 ++t;
2348 }
2349
2350 break;
2351
2352 case down:
2353 wx=3;
2354 wy=-14;
2355 if (IsSideSwim())wy+=hammer_swim_down_offset;
2356 t+=3;
2357
2358 if(attackclk>=13)
2359 {
2360 wy+=16;
2361 ++t;
2362 }
2363
2364 if(attackclk>=15)
2365 {
2366 wx-=1;
2367 wy+=12;
2368 if (IsSideSwim())wy-=hammer_swim_down_offset;
2369 ++t;
2370 }
2371
2372 break;
2373
2374 case left:
2375 wx=0;
2376 wy=-14;
2377 if (IsSideSwim())wy+=hammer_swim_left_offset;
2378 t+=6;
2379 f=1;
2380
2381 if(attackclk>=13)
2382 {
2383 wx-=7;
2384 wy+=8;
2385 ++t;
2386 }
2387
2388 if(attackclk>=15)
2389 {
2390 wx-=8;
2391 wy+=8;
2392 if (IsSideSwim())wy-=hammer_swim_left_offset;
2393 ++t;
2394 }
2395
2396 break;
2397
2398 case right:
2399 wx=0;
2400 wy=-14;
2401 if (IsSideSwim())wy+=hammer_swim_right_offset;
2402 t+=6;
2403
2404 if(attackclk>=13)
2405 {
2406 wx+=7;
2407 wy+=8;
2408 ++t;
2409 }
2410
2411 if(attackclk>=15)
2412 {
2413 wx+=8;
2414 wy+=8;
2415 if (IsSideSwim())wy-=hammer_swim_right_offset;
2416 ++t;
2417 }
2418
2419 break;
2420 }
2421
2422 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2423 {
2424 wy+=2;
2425 }
2426
2427 // Stone of Agony
2428 if(agony)
2429 {
2430 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2431 }
2432
2433 w->x = x+wx;
2434 w->y = y+wy-(54-yofs)-fakez;
2435 w->z = (z+zofs);
2436 w->tile = t;
2437 w->flip = f;
2438 w->hxsz=20;
2439 w->hysz=20;
2440
2441 if(dir>down)
2442 {
2443 w->hysz-=6;
2444 }
2445 else
2446 {
2447 w->hxsz-=6;
2448 w->hyofs=4;
2449 }
2450
2451 w->power = weaponattackpower(itemid);
2452
2453 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2454 {
2455 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2456 }
2457
2458 xofs=oxofs;
2459 yofs=oyofs;
2460 return;
2461 }
2462 62153 }
2463
2/4
✓ Branch 0 taken 1936914 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1936914 times.
1936914 else if(!charging && !spins) // remove the sword
2464 {
2465
2/2
✓ Branch 0 taken 582140 times.
✓ Branch 1 taken 1936914 times.
2519054 for(int32_t i=0; i<Lwpns.Count(); i++)
2466 {
2467 582140 weapon *w = (weapon*)Lwpns.spr(i);
2468
2469
3/6
✓ Branch 0 taken 582140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582140 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 582140 times.
582140 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2470 w->dead=1;
2471 582140 }
2472 1936914 }
2473
2474
2/2
✓ Branch 0 taken 8047 times.
✓ Branch 1 taken 1991020 times.
1999067 if(invisible)
2475 {
2476 8047 xofs=oxofs;
2477 8047 yofs=oyofs;
2478 8047 return;
2479 }
2480
2481
2/4
✓ Branch 0 taken 1991020 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1991020 times.
1991020 if(action != casting && action != sideswimcasting)
2482 {
2483 // Keep this consistent with checkspecial2, line 7800-ish...
2484
6/6
✓ Branch 0 taken 41751 times.
✓ Branch 1 taken 1949269 times.
✓ Branch 2 taken 37582 times.
✓ Branch 3 taken 4169 times.
✓ Branch 4 taken 3659 times.
✓ Branch 5 taken 33923 times.
1991020 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2485
2486 1991020 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2487 1991020 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2488 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2489
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1980303 times.
✓ Branch 3 taken 10717 times.
1991020 switch(zinit.heroAnimationStyle)
2490 {
2491 case las_original: //normal
2492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980303 times.
1980303 if(action==drowning)
2493 {
2494 if(inwater)
2495 {
2496 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2497 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2498 }
2499 else
2500 {
2501 xofs=oxofs;
2502 yofs=oyofs;
2503 return;
2504 }
2505 }
2506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980303 times.
1980303 else if(action==lavadrowning)
2507 {
2508 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2509 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2510 }
2511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980303 times.
1980303 else if(action==sidedrowning)
2512 {
2513 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2514 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2515 }
2516
2/4
✓ Branch 0 taken 1980303 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1980303 times.
1980303 else if (action == sideswimming || action == sideswimhit)
2517 {
2518 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2519
2520 if(lstep>=6)
2521 {
2522 if(dir==up)
2523 {
2524 if ( script_hero_sprite <= 0 ) ++flip;
2525 }
2526 else
2527 {
2528 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2529 }
2530 }
2531 }
2532
5/6
✓ Branch 0 taken 1970389 times.
✓ Branch 1 taken 9914 times.
✓ Branch 2 taken 1970359 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1970359 times.
1980303 else if(action==swimming || action==swimhit || hopclk==0xFF)
2533 {
2534 9944 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2535
2536
2/2
✓ Branch 0 taken 4990 times.
✓ Branch 1 taken 4954 times.
9944 if(lstep>=6)
2537 {
2538
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 4454 times.
4954 if(dir==up)
2539 {
2540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 if ( script_hero_sprite <= 0 ) ++flip;
2541 500 }
2542 else
2543 {
2544
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454 times.
4454 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2545 }
2546 4954 }
2547
2548
2/2
✓ Branch 0 taken 8516 times.
✓ Branch 1 taken 1428 times.
9944 if(isDiving())
2549 {
2550 1428 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1428 times.
1428 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2552 1428 }
2553 9944 }
2554
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1970359 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1970359 else if(charging > 0 && attack != wHammer)
2555 {
2556 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2557
2558 if(lstep>=6)
2559 {
2560 if(dir==up)
2561 {
2562 if ( script_hero_sprite <= 0 ) ++flip;
2563 }
2564 else
2565 {
2566 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2567 }
2568 }
2569 }
2570
3/12
✓ Branch 0 taken 1970359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1970359 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1970359 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1970359 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2571 {
2572 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2573 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2574 }
2575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970359 times.
1970359 else if(fallclk>0)
2576 {
2577 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2578 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2579 }
2580
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1970359 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1970359 else if(!noliftspr&&action==lifting&&isLifting())
2581 {
2582 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2583 if(script_hero_sprite <= 0)
2584 {
2585 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2586 auto speed = tliftclk/frames;
2587 if (speed < 1) speed = 1;
2588 auto curframe = (tliftclk - liftclk) / speed;
2589 if (!tliftclk) curframe = frames - 1;
2590 if(unsigned(curframe) < frames)
2591 tile += curframe * (extend == 2 ? 2 : 1);
2592 }
2593 }
2594 else
2595 {
2596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970359 times.
1970359 if(IsSideSwim())
2597 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2598
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1970359 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1970359 else if(!noliftspr&&isLifting())
2599 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2600 1970359 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2601
2602
2/2
✓ Branch 0 taken 1448721 times.
✓ Branch 1 taken 521638 times.
1970359 if(dir>up)
2603 {
2604 1448721 useltm=true;
2605 1448721 shieldModify=true;
2606 1448721 }
2607
2608
2/2
✓ Branch 0 taken 947437 times.
✓ Branch 1 taken 1022922 times.
1970359 if(lstep>=6)
2609 {
2610
2/2
✓ Branch 0 taken 265022 times.
✓ Branch 1 taken 757900 times.
1022922 if(dir==up)
2611 {
2612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265022 times.
265022 if ( script_hero_sprite <= 0 ) ++flip;
2613 265022 }
2614 else
2615 {
2616
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 757900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 757900 times.
757900 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2617 }
2618 1022922 }
2619 }
2620
2621 1980303 break;
2622
2623 case las_bszelda: //BS
2624
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 10525 times.
10717 if(action==drowning)
2625 {
2626
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(inwater)
2627 {
2628 192 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2630 192 }
2631 else
2632 {
2633 xofs=oxofs;
2634 yofs=oyofs;
2635 return;
2636 }
2637 192 }
2638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10525 times.
10525 else if (action == sidedrowning)
2639 {
2640 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2641 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2642 }
2643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10525 times.
10525 else if(action==lavadrowning)
2644 {
2645 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2646 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2647 }
2648
2/4
✓ Branch 0 taken 10525 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10525 times.
10525 else if (action == sideswimming || action == sideswimhit)
2649 {
2650 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2651
2652 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2653 }
2654
3/6
✓ Branch 0 taken 10525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10525 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10525 times.
10525 else if(action==swimming || action==swimhit || hopclk==0xFF)
2655 {
2656 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2657 {
2658 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2659 }
2660 else
2661 {
2662 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2663 }
2664 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2665
2666 if(isDiving())
2667 {
2668 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2669 {
2670 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2671 }
2672 else
2673 {
2674 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2675 }
2676 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2677 }
2678 }
2679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10525 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10525 else if(charging > 0 && attack != wHammer)
2680 {
2681 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2682 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2683 }
2684
8/10
✓ Branch 0 taken 10405 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 10405 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1566 times.
✓ Branch 5 taken 8959 times.
✓ Branch 6 taken 1193 times.
✓ Branch 7 taken 373 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1193 times.
10525 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2685 {
2686 1193 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1193 times.
1193 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2688 1193 }
2689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 else if(fallclk>0)
2690 {
2691 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2692 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2693 }
2694
2/6
✓ Branch 0 taken 9332 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9332 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9332 else if(!noliftspr&&action==lifting&&isLifting())
2695 {
2696 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2697 if(script_hero_sprite <= 0)
2698 {
2699 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2700 auto speed = tliftclk/frames;
2701 if (speed < 1) speed = 1;
2702 auto curframe = (tliftclk - liftclk) / speed;
2703 if (!tliftclk) curframe = frames - 1;
2704 if(unsigned(curframe) < frames)
2705 tile += curframe * (extend == 2 ? 2 : 1);
2706 }
2707 }
2708 else
2709 {
2710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 if(IsSideSwim())
2711 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2712
2/4
✓ Branch 0 taken 9332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9332 times.
✗ Branch 3 not taken.
9332 else if(!noliftspr&&isLifting())
2713 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2714 9332 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2715
2716
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7720 times.
9332 if(dir>up)
2717 {
2718 7720 useltm=true;
2719 7720 shieldModify=true;
2720 7720 }
2721
2722 /*
2723 else if (dir==up)
2724 {
2725 useltm=true;
2726 }
2727 */
2728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2729 }
2730
2731 10717 break;
2732
2733 case las_zelda3slow: //8-frame Zelda 3 (slow)
2734 case las_zelda3: //8-frame Zelda 3
2735 if(action == drowning)
2736 {
2737 if(inwater)
2738 {
2739 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2740 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2741 }
2742 else
2743 {
2744 xofs=oxofs;
2745 yofs=oyofs;
2746 return;
2747 }
2748 }
2749 else if(action == lavadrowning)
2750 {
2751 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2752 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2753
2754 }
2755 else if(action == sidedrowning)
2756 {
2757 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2758 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2759 }
2760 else if (action == sideswimming || action == sideswimhit)
2761 {
2762 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2763
2764 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2765 }
2766 else if(action == swimming || action==swimhit || hopclk==0xFF)
2767 {
2768 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2769 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2770
2771 if(isDiving())
2772 {
2773 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2774 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2775 }
2776 }
2777 else if(charging > 0 && attack != wHammer)
2778 {
2779 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2780 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2781 //int32_t l=hero_count/hero_animation_speed;
2782 int32_t l=(hero_count/hero_animation_speed)&15;
2783 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2784 l-=((l>3)?1:0)+((l>12)?1:0);
2785 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2786 }
2787 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2788 {
2789 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2790 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2791 }
2792 else if(fallclk>0)
2793 {
2794 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2795 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2796 }
2797 else if(!noliftspr&&action==lifting&&isLifting())
2798 {
2799 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2800 if(script_hero_sprite <= 0)
2801 {
2802 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2803 auto speed = tliftclk/frames;
2804 if (speed < 1) speed = 1;
2805 auto curframe = (tliftclk-liftclk)/speed;
2806 if (!tliftclk) curframe = frames - 1;
2807 if(unsigned(curframe) < frames)
2808 tile += curframe * (extend == 2 ? 2 : 1);
2809 }
2810 }
2811 else
2812 {
2813 if(IsSideSwim())
2814 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2815 else if(!noliftspr&&isLifting())
2816 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2817 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2818
2819 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2820 {
2821 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2822 }
2823
2824 if(dir>up)
2825 {
2826 useltm=true;
2827 shieldModify=true;
2828 }
2829
2830 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2831 {
2832 //tile+=(extend==2?2:1);
2833 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2834 int32_t l = hero_count / hero_animation_speed;
2835 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2836 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2837 }
2838 }
2839
2840 break;
2841
2842 default:
2843 break;
2844 }
2845 1991020 }
2846
2847
6/6
✓ Branch 0 taken 1980303 times.
✓ Branch 1 taken 10717 times.
✓ Branch 2 taken 1460434 times.
✓ Branch 3 taken 519869 times.
✓ Branch 4 taken 89025 times.
✓ Branch 5 taken 1371409 times.
1991020 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2848
2849
2/2
✓ Branch 0 taken 1990653 times.
✓ Branch 1 taken 367 times.
1991020 if(action==won)
2850 {
2851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2852 367 }
2853
2854
4/4
✓ Branch 0 taken 1974330 times.
✓ Branch 1 taken 16690 times.
✓ Branch 2 taken 21886 times.
✓ Branch 3 taken 1952444 times.
1991020 if(action==landhold1 || action==landhold2)
2855 {
2856 38576 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2857
5/6
✓ Branch 0 taken 38576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30357 times.
✓ Branch 3 taken 8219 times.
✓ Branch 4 taken 10057 times.
✓ Branch 5 taken 20300 times.
38576 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2858 38576 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2859 38576 }
2860
3/4
✓ Branch 0 taken 1952184 times.
✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1952184 times.
1952444 else if(action==waterhold1 || action==waterhold2)
2861 {
2862 260 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2863 260 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2864 260 }
2865
2/4
✓ Branch 0 taken 1952184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1952184 times.
1952184 else if(action==sidewaterhold1 || action==sidewaterhold2)
2866 {
2867 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2868 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2869 }
2870
2871
2/4
✓ Branch 0 taken 1991020 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1991020 times.
1991020 if(action!=casting && action!=sideswimcasting)
2872 {
2873
2/2
✓ Branch 0 taken 550393 times.
✓ Branch 1 taken 1440627 times.
1991020 if(useltm)
2874 {
2875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1440627 times.
1440627 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2876 1440627 }
2877 1991020 }
2878
2879 // Stone of Agony
2880
1/2
✓ Branch 0 taken 1991020 times.
✗ Branch 1 not taken.
1991020 if(agony)
2881 {
2882 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2883 }
2884
2885
6/6
✓ Branch 0 taken 392324 times.
✓ Branch 1 taken 1598696 times.
✓ Branch 2 taken 384880 times.
✓ Branch 3 taken 7444 times.
✓ Branch 4 taken 13854 times.
✓ Branch 5 taken 378470 times.
1991020 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2886 {
2887 1977166 masked_draw(dest);
2888 1977166 }
2889
2890 //draw held items after Hero so they don't go behind his head
2891
4/4
✓ Branch 0 taken 1974330 times.
✓ Branch 1 taken 16690 times.
✓ Branch 2 taken 21886 times.
✓ Branch 3 taken 1952444 times.
1991020 if(action==landhold1 || action==landhold2)
2892 {
2893
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 38574 times.
38576 if(holditem > -1)
2894 {
2895
2/2
✓ Branch 0 taken 8115 times.
✓ Branch 1 taken 30459 times.
38574 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2896 {
2897 8115 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2898 8115 }
2899 else
2900 {
2901 30459 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2902 }
2903 38574 }
2904 38576 }
2905
3/4
✓ Branch 0 taken 1952184 times.
✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1952184 times.
1952444 else if(action==waterhold1 || action==waterhold2)
2906 {
2907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(holditem > -1)
2908 {
2909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2910 {
2911 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2912 }
2913 else
2914 {
2915 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2916 }
2917 260 }
2918 260 }
2919
2/4
✓ Branch 0 taken 1952184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1952184 times.
1952184 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2920 {
2921 if(holditem > -1)
2922 {
2923 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2924 {
2925 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2926 }
2927 else
2928 {
2929 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2930 }
2931 }
2932 }
2933
3/4
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 1982780 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8240 times.
1991020 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2934 {
2935 1982780 xofs=oxofs;
2936 1982780 yofs=oyofs;
2937 1982780 return;
2938 }
2939
2940 8240 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2941 8240 int32_t hearts=0;
2942 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2943 8240 int32_t htile = 2;
2944
2945 8240 do
2946 {
2947 54720 int32_t nx=125;
2948
2949
2/2
✓ Branch 0 taken 45552 times.
✓ Branch 1 taken 9168 times.
54720 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2950 {
2951 9168 nx=x;
2952 9168 }
2953
2954 54720 int32_t ny=88;
2955
2956
2/2
✓ Branch 0 taken 45552 times.
✓ Branch 1 taken 9168 times.
54720 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2957 {
2958 9168 ny=y;
2959 9168 }
2960
2961 54720 double tx = zc::math::Cos(a2)*53 +nx;
2962 54720 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2963 54720 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2964 54720 a2-=PI/4;
2965 54720 ++hearts;
2966
2/2
✓ Branch 0 taken 46480 times.
✓ Branch 1 taken 8240 times.
109440 }
2967
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 51520 times.
54720 while(a2>PI/2 && hearts<8);
2968
2969 8240 xofs=oxofs;
2970 8240 yofs=oyofs;
2971 2255360 }
2972
2973 2230237 void HeroClass::masked_draw(BITMAP* dest)
2974 {
2975
12/12
✓ Branch 0 taken 1657074 times.
✓ Branch 1 taken 573163 times.
✓ Branch 2 taken 1560548 times.
✓ Branch 3 taken 96526 times.
✓ Branch 4 taken 1538835 times.
✓ Branch 5 taken 21713 times.
✓ Branch 6 taken 1514836 times.
✓ Branch 7 taken 23999 times.
✓ Branch 8 taken 1483730 times.
✓ Branch 9 taken 31106 times.
✓ Branch 10 taken 1505334 times.
✓ Branch 11 taken 55214 times.
2230237 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
2976 {
2977 // clip under doorways
2978 55214 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
2979
2980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55214 times.
55214 if(sub!=NULL)
2981 {
2982 55214 yofs -= (playing_field_offset+16);
2983 55214 xofs -= 16;
2984 55214 sprite::draw(sub);
2985
1/2
✓ Branch 0 taken 55214 times.
✗ Branch 1 not taken.
55214 if(lift_wpn)
2986 {
2987 handle_lift(false);
2988 bool shad = lift_wpn->has_shadow;
2989 lift_wpn->has_shadow = false;
2990 lift_wpn->draw(sub);
2991 lift_wpn->has_shadow = shad;
2992 }
2993 55214 prompt_draw(sub);
2994 55214 xofs+=16;
2995 55214 yofs += (playing_field_offset+16);
2996 55214 destroy_bitmap(sub);
2997 55214 }
2998 55214 }
2999 else
3000 {
3001 2175023 sprite::draw(dest);
3002
1/2
✓ Branch 0 taken 2175023 times.
✗ Branch 1 not taken.
2175023 if(lift_wpn)
3003 {
3004 handle_lift(false);
3005 bool shad = lift_wpn->has_shadow;
3006 lift_wpn->has_shadow = false;
3007 lift_wpn->draw(dest);
3008 lift_wpn->has_shadow = shad;
3009 }
3010 2175023 prompt_draw(dest);
3011 }
3012
3013 2230237 return;
3014 }
3015 2230237 void HeroClass::prompt_draw(BITMAP* dest)
3016 {
3017
1/2
✓ Branch 0 taken 2230237 times.
✗ Branch 1 not taken.
2230237 if(!prompt_combo) return;
3018 int32_t sx = real_x(x+xofs+prompt_x);
3019 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3020 sy -= fake_z(fakez);
3021 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3022 return;
3023 2230237 }
3024
3025 3569 void collectitem_script(int32_t id)
3026 {
3027
1/2
✓ Branch 0 taken 3569 times.
✗ Branch 1 not taken.
3569 if(itemsbuf[id].collect_script)
3028 {
3029 //clear item script stack.
3030 //ri = &(itemScriptData[id]);
3031 //ri->Clear();
3032 //itemCollectScriptData[id].Clear();
3033 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3034 ri = &(itemCollectScriptData[id]);
3035 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3036 ri->Clear();
3037 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3038
3039 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3040 {
3041 item_collect_doscript[id] = 1;
3042 itemscriptInitialised[id] = 0;
3043 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3044 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3045 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3046 }
3047 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3048 {
3049 item_collect_doscript[id] = 1;
3050 itemscriptInitialised[id] = 0;
3051 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3052 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3053 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3054 }
3055 //runningItemScripts[id] = 0;
3056 }
3057 3569 }
3058 265 void passiveitem_script(int32_t id, bool doRun = false)
3059 {
3060 //Passive item scripts on colelction
3061
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
265 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3062 {
3063 ri = &(itemScriptData[id]);
3064 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3065 ri->Clear();
3066 item_doscript[id] = 1;
3067 itemscriptInitialised[id] = 0;
3068
3069
3070 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3071 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3072 {
3073 item_doscript[id] = 0;
3074 return;
3075 }
3076 if(doRun)
3077 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3078 }
3079 265 }
3080
3081 // separate case for sword/wand/hammer/slashed weapons only
3082 // the main weapon checking is in the global function check_collisions()
3083 1981852 bool HeroClass::checkstab()
3084 {
3085
12/14
✓ Branch 0 taken 1667051 times.
✓ Branch 1 taken 314801 times.
✓ Branch 2 taken 69937 times.
✓ Branch 3 taken 244864 times.
✓ Branch 4 taken 65651 times.
✓ Branch 5 taken 4286 times.
✓ Branch 6 taken 65651 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 65651 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 63246 times.
✓ Branch 11 taken 2405 times.
✓ Branch 12 taken 73217 times.
✓ Branch 13 taken 178338 times.
1981852 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3086 314801 || (attackclk<=4))
3087 1803514 return false;
3088
3089 178338 weapon *w=NULL;
3090
3091 178338 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3092 178338 bool found = false;
3093 178338 int32_t melee_weapon_index = 0;
3094 178338 int32_t parentitem=-1;
3095 178338 weapon* meleeweap = nullptr;
3096
2/2
✓ Branch 0 taken 19581 times.
✓ Branch 1 taken 196124 times.
215705 for(int32_t i=0; i<Lwpns.Count(); i++)
3097 {
3098 196124 w = (weapon*)Lwpns.spr(i);
3099
3100
5/6
✓ Branch 0 taken 196124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2085 times.
✓ Branch 3 taken 194039 times.
✓ Branch 4 taken 37367 times.
✓ Branch 5 taken 158757 times.
196124 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3101 {
3102 158757 found = true;
3103 158757 melee_weapon_index = i+1;
3104 158757 meleeweap = w;
3105 // Position the sword as Hero slashes with it.
3106
2/4
✓ Branch 0 taken 158757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 158757 times.
158757 if(w->id!=wHammer&&w->id!=wBugNet)
3107 158757 positionSword(w,w->parentitem);
3108
3109 158757 wx=w->x;
3110 158757 wy=w->y;
3111 158757 wz=w->z;
3112 158757 wxsz = w->hxsz;
3113 158757 wysz = w->hysz;
3114 158757 parentitem = w->parentitem;
3115 158757 break;
3116 }
3117 37367 }
3118
3119
5/6
✓ Branch 0 taken 173622 times.
✓ Branch 1 taken 4716 times.
✓ Branch 2 taken 17153 times.
✓ Branch 3 taken 156469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17153 times.
178338 if(attack==wSword && attackclk>=14 && charging==0)
3120 17153 return false;
3121
3122
2/2
✓ Branch 0 taken 141604 times.
✓ Branch 1 taken 19581 times.
161185 if(!found)
3123 19581 return false;
3124
3125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141604 times.
141604 if(attack == wFire)
3126 return false;
3127
3128
1/2
✓ Branch 0 taken 141604 times.
✗ Branch 1 not taken.
141604 if(attack==wHammer)
3129 {
3130 if(attackclk<15)
3131 {
3132 switch(w->dir)
3133 {
3134 case up:
3135 wx=x-1;
3136 wy=y-4;
3137 break;
3138
3139 case down:
3140 wx=x+8;
3141 wy=y+28;
3142 break; // This is consistent with 2.10
3143
3144 case left:
3145 wx=x-13;
3146 wy=y+14;
3147 break;
3148
3149 case right:
3150 wx=x+21;
3151 wy=y+14;
3152 break;
3153 }
3154
3155 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3156 {
3157 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3158 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3159 switch(dir)
3160 {
3161 case up:
3162 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3163 break;
3164
3165 case down:
3166 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3167 break;
3168
3169 case left:
3170 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3171 break;
3172
3173 case right:
3174 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3175 break;
3176 }
3177 */
3178 }
3179
3180 return false;
3181 }
3182 else if(attackclk==15)
3183 {
3184 // Hammer's reach needs adjusted slightly for backward compatibility
3185 if(w->dir==up)
3186 w->hyofs-=1;
3187 else if(w->dir==left)
3188 w->hxofs-=2;
3189 }
3190 }
3191
3192 // The return of Spaghetti Code Constants!
3193
3/6
✓ Branch 0 taken 2743 times.
✓ Branch 1 taken 138861 times.
✓ Branch 2 taken 138861 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
141604 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141604 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3195 141604 itemid = vbound(itemid, 0, MAXITEMS-1);
3196
3197 // The sword offsets aren't based on anything other than what felt about right
3198 // compared to the NES game and what mostly kept it from hitting things that
3199 // should clearly be out of range. They could probably still use more tweaking.
3200 // Don't use 2.10 for reference; it's pretty far off.
3201 // - Saf
3202
3203
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 141604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
141604 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3204 {
3205 switch(w->dir)
3206 {
3207 case up:
3208 if(attackclk<8)
3209 {
3210 wy-=4;
3211 }
3212
3213 break;
3214
3215 case down:
3216 //if(attackclk<8)
3217 {
3218 wy-=2;
3219 }
3220 break;
3221
3222 case left:
3223
3224 //if(attackclk<8)
3225 {
3226 wx+=2;
3227 }
3228
3229 break;
3230
3231 case right:
3232
3233 //if(attackclk<8)
3234 {
3235 wx-=3;
3236 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3237 }
3238
3239 break;
3240 }
3241 }
3242
3243
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31251 times.
✓ Branch 2 taken 29196 times.
✓ Branch 3 taken 40548 times.
✓ Branch 4 taken 40609 times.
141604 switch(w->dir)
3244 {
3245 case up:
3246 31251 wx+=2;
3247 31251 break;
3248
3249 case down:
3250 29196 break;
3251
3252 case left:
3253 40548 wy-=3;
3254 40548 break;
3255
3256 case right:
3257 40609 wy-=3;
3258 40609 break;
3259 }
3260
3261 141604 wx+=w->hxofs;
3262 141604 wy+=w->hyofs;
3263 141604 wy-=(w->fakez).getInt();
3264
3265
2/2
✓ Branch 0 taken 140152 times.
✓ Branch 1 taken 728272 times.
868424 for(int32_t i=0; i<guys.Count(); i++)
3266 {
3267
1/2
✓ Branch 0 taken 728272 times.
✗ Branch 1 not taken.
728272 if(attack==wBugNet) break;
3268 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3269
5/6
✓ Branch 0 taken 14772 times.
✓ Branch 1 taken 713500 times.
✓ Branch 2 taken 14717 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 14717 times.
✗ Branch 5 not taken.
728272 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3270
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 688821 times.
✓ Branch 3 taken 24679 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 713500 times.
713555 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 713500 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
713500 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3272 {
3273 // Checking the whimsical ring for every collision check causes
3274 // an odd bug. It's much more likely to activate on a 0-damage
3275 // weapon, since a 0-damage hit won't make the enemy invulnerable
3276 // to damaging hits in the following frames.
3277
3278 14772 int32_t whimsyid = current_item_id(itype_whimsicalring);
3279
3280 14772 int32_t dmg = weaponattackpower(itemid);
3281
1/2
✓ Branch 0 taken 14772 times.
✗ Branch 1 not taken.
14772 if(whimsyid>-1)
3282 {
3283 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3284 dmg += current_item_power(itype_whimsicalring);
3285 else whimsyid = -1;
3286 }
3287 14772 int32_t atkringid = current_item_id(itype_atkring);
3288
1/2
✓ Branch 0 taken 14772 times.
✗ Branch 1 not taken.
14772 if(atkringid>-1)
3289 {
3290 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3291 dmg += itemsbuf[atkringid].misc1; //Additive
3292 }
3293
3294 14772 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn);
3295 14772 enemy *e = (enemy*)guys.spr(i);
3296
2/2
✓ Branch 0 taken 4525 times.
✓ Branch 1 taken 10247 times.
14772 if (h == -1) { e->hitby[HIT_BY_LWEAPON] = melee_weapon_index; } //temp_hit = true; }
3297 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3298
3299
3/4
✓ Branch 0 taken 10247 times.
✓ Branch 1 taken 4525 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10247 times.
14772 if(h<0 && whimsyid>-1)
3300 {
3301 sfx(itemsbuf[whimsyid].usesound);
3302 }
3303
3304
3/4
✓ Branch 0 taken 13086 times.
✓ Branch 1 taken 1686 times.
✓ Branch 2 taken 13086 times.
✗ Branch 3 not taken.
14772 if(h && charging>0)
3305 {
3306 attackclk = SWORDTAPFRAME;
3307 spins=0;
3308 }
3309
3310
6/8
✓ Branch 0 taken 13086 times.
✓ Branch 1 taken 1686 times.
✓ Branch 2 taken 11956 times.
✓ Branch 3 taken 1130 times.
✓ Branch 4 taken 11956 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11956 times.
14772 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3311 {
3312
2/2
✓ Branch 0 taken 11923 times.
✓ Branch 1 taken 33 times.
11956 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3313 {
3314 33 hithero(i);
3315 33 }
3316 11956 }
3317
3318
2/2
✓ Branch 0 taken 13320 times.
✓ Branch 1 taken 1452 times.
14772 if(h==2)
3319 1452 break;
3320 13320 }
3321 726820 }
3322
3323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141604 times.
283208 if(attack == wBugNet
3324
2/4
✓ Branch 0 taken 141604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 141604 times.
141604 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3325
1/2
✓ Branch 0 taken 141604 times.
✗ Branch 1 not taken.
141604 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3326 {
3327
1/4
✓ Branch 0 taken 141604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141604 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3328
2/2
✓ Branch 0 taken 141604 times.
✓ Branch 1 taken 31686 times.
173290 for(int32_t j=0; j<items.Count(); j++)
3329 {
3330 31686 item* ptr = (item*)items.spr(j);
3331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31686 times.
31686 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3332 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3333
3334
2/4
✓ Branch 0 taken 31686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31686 times.
✗ Branch 3 not taken.
31686 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3335 continue; //No picking these up unless you have a bottle to fill!
3336
4/6
✓ Branch 0 taken 31686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5174 times.
✓ Branch 3 taken 26512 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5174 times.
31686 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3337 {
3338
6/8
✓ Branch 0 taken 26512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9326 times.
✓ Branch 3 taken 17186 times.
✓ Branch 4 taken 17186 times.
✓ Branch 5 taken 9326 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 17186 times.
26512 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3339 {
3340
6/6
✓ Branch 0 taken 16291 times.
✓ Branch 1 taken 895 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 16045 times.
✓ Branch 4 taken 16291 times.
✓ Branch 5 taken 895 times.
33477 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3341
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 16291 times.
✗ Branch 3 not taken.
16291 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3342 {
3343 895 int32_t pickup = ptr->pickup;
3344 895 int32_t id2 = ptr->id;
3345 895 int32_t pstr = ptr->pstring;
3346 895 int32_t pstr_flags = ptr->pickup_string_flags;
3347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
895 if(!dofairy)
3348 {
3349 895 std::vector<int32_t> &ev = FFCore.eventData;
3350 895 ev.clear();
3351 895 ev.push_back(id2*10000);
3352 895 ev.push_back(pickup*10000);
3353 895 ev.push_back(pstr*10000);
3354 895 ev.push_back(pstr_flags*10000);
3355 895 ev.push_back(0);
3356 895 ev.push_back(ptr->getUID());
3357 895 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3358 895 ev.push_back(w->getUID());
3359
3360 895 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3361 895 bool nullify = ev[4] != 0;
3362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
895 if(nullify) continue;
3363 895 id2 = ev[0]/10000;
3364 895 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3365 895 pstr = ev[2] / 10000;
3366 895 pstr_flags = ev[3] / 10000;
3367 895 }
3368
3369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
895 if(pickup&ipONETIME) // set mITEM for one-time-only items
3370 setmapflag(mITEM);
3371
1/2
✓ Branch 0 taken 895 times.
✗ Branch 1 not taken.
895 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3372 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3373
3374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
895 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3375 setxmapflag(1<<ptr->pickupexstate);
3376
1/2
✓ Branch 0 taken 895 times.
✗ Branch 1 not taken.
895 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3377 {
3378 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3379 hidden_entrance(0, true, false, -5);
3380 }
3381 //!DIMI
3382
3383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
895 if(dofairy)
3384 {
3385 game->fillBottle(itemsbuf[ptr->id].misc4);
3386 }
3387 else
3388 {
3389 895 collectitem_script(id2);
3390
3391 895 getitem(id2, false, true);
3392 }
3393 895 items.del(j);
3394
3395
2/2
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 895 times.
1985 for(int32_t i=0; i<Lwpns.Count(); i++)
3396 {
3397 1090 weapon *w2 = (weapon*)Lwpns.spr(i);
3398
3399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1090 times.
1090 if(w2->dragging==j)
3400 {
3401 w2->dragging=-1;
3402 }
3403
1/2
✓ Branch 0 taken 1090 times.
✗ Branch 1 not taken.
1090 else if(w2->dragging>j)
3404 {
3405 w2->dragging-=1;
3406 }
3407 1090 }
3408
3409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
895 if ( (pstr > 0 && pstr < msg_count) )
3410 {
3411 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3412 {
3413 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3414 FFCore.SetItemMessagePlayed(id2);
3415 donewmsg(pstr);
3416 break;
3417 }
3418 }
3419
3420 895 --j;
3421 895 }
3422 17186 }
3423 26512 }
3424 31686 }
3425 141604 }
3426
3427
2/4
✓ Branch 0 taken 141604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 141604 times.
141604 if(attack==wCByrna || attack==wBugNet)
3428 return false;
3429
3430
2/2
✓ Branch 0 taken 138861 times.
✓ Branch 1 taken 2743 times.
141604 if(attack==wSword)
3431 {
3432
2/2
✓ Branch 0 taken 121330 times.
✓ Branch 1 taken 17531 times.
138861 if(attackclk == 6)
3433 {
3434
2/2
✓ Branch 0 taken 3085456 times.
✓ Branch 1 taken 17531 times.
3102987 for(int32_t q=0; q<176; q++)
3435 {
3436 3085456 set_bit(screengrid,q,0);
3437 3085456 set_bit(screengrid_layer[0],q,0);
3438 3085456 set_bit(screengrid_layer[1],q,0);
3439
3440 3085456 }
3441
3442
2/2
✓ Branch 0 taken 280496 times.
✓ Branch 1 taken 17531 times.
298027 for(dword q = MAXFFCS/8; q > 0; --q)
3443 280496 ffcgrid[q-1] = 0;
3444 17531 }
3445
3446
4/4
✓ Branch 0 taken 30981 times.
✓ Branch 1 taken 107880 times.
✓ Branch 2 taken 16059 times.
✓ Branch 3 taken 14922 times.
138861 if(dir==up && ((x.getInt()&15)==0))
3447 {
3448 14922 check_slash_block(wx,wy);
3449 14922 check_slash_block(wx,wy+8);
3450
3451 //layers
3452 14922 check_slash_block_layer(wx,wy,1);
3453 14922 check_slash_block_layer(wx,wy+8,1);
3454 14922 check_slash_block_layer(wx,wy,1);
3455 14922 check_slash_block_layer(wx,wy+8,1);
3456 //2
3457 14922 check_slash_block_layer(wx,wy,2);
3458 14922 check_slash_block_layer(wx,wy+8,2);
3459 14922 check_slash_block_layer(wx,wy,2);
3460 14922 check_slash_block_layer(wx,wy+8,2);
3461
3462
3463
3464 14922 }
3465
3/8
✓ Branch 0 taken 16059 times.
✓ Branch 1 taken 107880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16059 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
123939 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3466 {
3467 16059 check_slash_block(wx,wy);
3468 16059 check_slash_block(wx,wy+8);
3469 16059 check_slash_block(wx+8,wy);
3470 16059 check_slash_block(wx+8,wy+8);
3471 ///layer 1
3472 16059 check_slash_block_layer(wx,wy,1);
3473 16059 check_slash_block_layer(wx,wy+8,1);
3474 16059 check_slash_block_layer(wx+8,wy,1);
3475 16059 check_slash_block_layer(wx+8,wy+8,1);
3476 ///layer 2
3477 16059 check_slash_block_layer(wx,wy,2);
3478 16059 check_slash_block_layer(wx,wy+8,2);
3479 16059 check_slash_block_layer(wx+8,wy,2);
3480 16059 check_slash_block_layer(wx+8,wy+8,2);
3481 16059 }
3482
3483
4/4
✓ Branch 0 taken 28737 times.
✓ Branch 1 taken 110124 times.
✓ Branch 2 taken 15644 times.
✓ Branch 3 taken 13093 times.
138861 if(dir==down && ((x.getInt()&15)==0))
3484 {
3485 15644 check_slash_block(wx,wy+wysz-8);
3486 15644 check_slash_block(wx,wy+wysz);
3487
3488 //layer 1
3489 15644 check_slash_block_layer(wx,wy+wysz-8,1);
3490 15644 check_slash_block_layer(wx,wy+wysz,1);
3491 //layer 2
3492 15644 check_slash_block_layer(wx,wy+wysz-8,2);
3493 15644 check_slash_block_layer(wx,wy+wysz,2);
3494 15644 }
3495
3/8
✓ Branch 0 taken 13093 times.
✓ Branch 1 taken 110124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13093 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
123217 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3496 {
3497 13093 check_slash_block(wx,wy+wysz-8);
3498 13093 check_slash_block(wx,wy+wysz);
3499 13093 check_slash_block(wx+8,wy+wysz-8);
3500 13093 check_slash_block(wx+8,wy+wysz);
3501 //layer 1
3502 13093 check_slash_block_layer(wx,wy+wysz-8,1);
3503 13093 check_slash_block_layer(wx,wy+wysz,1);
3504 13093 check_slash_block_layer(wx+8,wy+wysz-8,1);
3505 13093 check_slash_block_layer(wx+8,wy+wysz,1);
3506 //layer 2
3507 13093 check_slash_block_layer(wx,wy+wysz-8,2);
3508 13093 check_slash_block_layer(wx,wy+wysz,2);
3509 13093 check_slash_block_layer(wx+8,wy+wysz-8,2);
3510 13093 check_slash_block_layer(wx+8,wy+wysz,2);
3511 13093 }
3512
3513
2/2
✓ Branch 0 taken 99638 times.
✓ Branch 1 taken 39223 times.
138861 if(dir==left)
3514 {
3515 39223 check_slash_block(wx,wy+8);
3516 39223 check_slash_block(wx+8,wy+8);
3517 //layer 1
3518 39223 check_slash_block_layer(wx,wy+8,1);
3519 39223 check_slash_block_layer(wx+8,wy+8,1);
3520 //layer 2
3521 39223 check_slash_block_layer(wx,wy+8,2);
3522 39223 check_slash_block_layer(wx+8,wy+8,2);
3523 39223 }
3524
3525
2/2
✓ Branch 0 taken 98941 times.
✓ Branch 1 taken 39920 times.
138861 if(dir==right)
3526 {
3527 39920 check_slash_block(wx+wxsz,wy+8);
3528 39920 check_slash_block(wx+wxsz-8,wy+8);
3529 //layer 1
3530 39920 check_slash_block_layer(wx+wxsz,wy+8,1);
3531 39920 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3532 //layer 2
3533 39920 check_slash_block_layer(wx+wxsz,wy+8,2);
3534 39920 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3535 39920 }
3536 138861 }
3537
1/2
✓ Branch 0 taken 2743 times.
✗ Branch 1 not taken.
2743 else if(attack==wWand)
3538 {
3539
1/2
✓ Branch 0 taken 2743 times.
✗ Branch 1 not taken.
2743 if(attackclk == 5)
3540 {
3541 for(int32_t q=0; q<176; q++)
3542 {
3543 set_bit(screengrid,q,0);
3544 set_bit(screengrid_layer[0],q,0);
3545 set_bit(screengrid_layer[1],q,0);
3546 }
3547
3548 for(dword q = MAXFFCS/8; q > 0; --q)
3549 ffcgrid[q-1] = 0;
3550 }
3551
3552 // cutable blocks
3553
4/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 2473 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 180 times.
2743 if(dir==up && (x.getInt()&15)==0)
3554 {
3555 180 check_wand_block(wx,wy);
3556 180 check_wand_block(wx,wy+8);
3557 180 }
3558
3/8
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 2473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2563 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3559 {
3560 90 check_wand_block(wx,wy);
3561 90 check_wand_block(wx,wy+8);
3562 90 check_wand_block(wx+8,wy);
3563 90 check_wand_block(wx+8,wy+8);
3564 90 }
3565
3566
4/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 181 times.
2743 if(dir==down && (x.getInt()&15)==0)
3567 {
3568 181 check_wand_block(wx,wy+wysz-8);
3569 181 check_wand_block(wx,wy+wysz);
3570 181 }
3571
3/8
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 2284 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2562 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3572 {
3573 278 check_wand_block(wx,wy+wysz-8);
3574 278 check_wand_block(wx,wy+wysz);
3575 278 check_wand_block(wx+8,wy+wysz-8);
3576 278 check_wand_block(wx+8,wy+wysz);
3577 278 }
3578
3579
2/2
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 1325 times.
2743 if(dir==left)
3580 {
3581 1325 check_wand_block(wx,y+8);
3582 1325 check_wand_block(wx+8,y+8);
3583 1325 }
3584
3585
2/2
✓ Branch 0 taken 2054 times.
✓ Branch 1 taken 689 times.
2743 if(dir==right)
3586 {
3587 689 check_wand_block(wx+wxsz,y+8);
3588 689 check_wand_block(wx+wxsz-8,y+8);
3589 689 }
3590 2743 }
3591 else if((attack==wHammer) && ((attackclk==15) || ( spins==1 && attackclk >=15 ))) //quake hammer should be spins == 1
3592 //else if((attack==wHammer) && (attackclk==15))
3593 //reverting this, because it breaks multiple-hit pegs
3594 //else if((attack==wHammer) && (attackclk>=15)) //>= instead of == for time it takes to charge up hammer with quake scrolls.
3595 {
3596 // poundable blocks
3597 for(int32_t q=0; q<176; q++)
3598 {
3599 set_bit(screengrid,q,0);
3600 set_bit(screengrid_layer[0],q,0);
3601 set_bit(screengrid_layer[1],q,0);
3602 }
3603
3604 for(dword q = MAXFFCS/8; q > 0; --q)
3605 ffcgrid[q-1] = 0;
3606
3607 if(dir==up && (x.getInt()&15)==0)
3608 {
3609 check_pound_block(wx,wy);
3610 check_pound_block(wx,wy+8);
3611 }
3612 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3613 {
3614 check_pound_block(wx,wy);
3615 check_pound_block(wx,wy+8);
3616 check_pound_block(wx+8,wy);
3617 check_pound_block(wx+8,wy+8);
3618 }
3619
3620 if(dir==down && (x.getInt()&15)==0)
3621 {
3622 check_pound_block(wx,wy+wysz-8);
3623 check_pound_block(wx,wy+wysz);
3624 }
3625 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3626 {
3627 check_pound_block(wx,wy+wysz-8);
3628 check_pound_block(wx,wy+wysz);
3629 check_pound_block(wx+8,wy+wysz-8);
3630 check_pound_block(wx+8,wy+wysz);
3631 }
3632
3633 if(dir==left)
3634 {
3635 check_pound_block(wx,y+8);
3636 check_pound_block(wx+8,y+8);
3637 }
3638
3639 if(dir==right)
3640 {
3641 check_pound_block(wx+wxsz,y+8);
3642 check_pound_block(wx+wxsz-8,y+8);
3643 }
3644 }
3645 else
3646 {
3647 return false;
3648 }
3649
3650 141604 return true;
3651 1981852 }
3652
3653 731740 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3654 {
3655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 731740 times.
731740 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3656 {
3657 //zprint("bit off\n");
3658 731740 return;
3659 }
3660 //keep things inside the screen boundaries
3661 bx=vbound(bx, 0, 255);
3662 by=vbound(by, 0, 176);
3663 int32_t fx=vbound(bx, 0, 255);
3664 int32_t fy=vbound(by, 0, 176);
3665 //first things first
3666 if(attack!=wSword)
3667 return;
3668
3669 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3670 || (attackclk>SWORDTAPFRAME && tapping))
3671 return;
3672
3673 //find out which combo row/column the coordinates are in
3674 bx &= 0xF0;
3675 by &= 0xF0;
3676
3677
3678 int32_t flag = MAPFLAGL(layer,bx,by);
3679 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3680 int32_t cid = MAPCOMBOL(layer,bx,by);
3681 int32_t type = combobuf[cid].type;
3682 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3683 type = cNONE;
3684 //zprint("cid is: %d\n", cid);
3685 //zprint("type is: %d\n", type);
3686 int32_t i = (bx>>4) + by;
3687
3688 if(i > 175)
3689 return;
3690
3691 bool ignorescreen=false;
3692
3693 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3694 return;
3695
3696 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3697
3698 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3699 if(isCuttableNextType(type))
3700 {
3701 FFCore.tempScreens[layer]->data[i]++;
3702 }
3703 else
3704 {
3705 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3706 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3707 FFCore.tempScreens[layer]->sflag[i] = 0;
3708 }
3709 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3710 {
3711 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3712 sfx(tmpscr->secretsfx);
3713 }
3714 else if(isCuttableItemType(type))
3715 {
3716 int32_t it = -1;
3717 int32_t thedropset = -1;
3718
3719 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3720 if ( (combobuf[cid].usrflags&cflag2) )
3721 {
3722 if(combobuf[cid].usrflags&cflag11)
3723 it = combobuf[cid].attribytes[1];
3724 else
3725 {
3726 it = select_dropitem(combobuf[cid].attribytes[1]);
3727 thedropset = combobuf[cid].attribytes[1];
3728 }
3729 }
3730 else
3731 {
3732 it = select_dropitem(12);
3733 thedropset = 12;
3734 }
3735 if(it!=-1)
3736 {
3737 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3738 itm->from_dropset = thedropset;
3739 items.add(itm);
3740 }
3741 }
3742
3743 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3744
3745 if(get_bit(quest_rules,qr_MORESOUNDS))
3746 {
3747 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3748 {
3749 if (combobuf[cid].usrflags&cflag3)
3750 {
3751 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3752 }
3753 }
3754 else
3755 {
3756 if (combobuf[cid].usrflags&cflag3)
3757 {
3758 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3759 }
3760 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3761 }
3762 }
3763
3764 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3765 if(decotype > 3) decotype = 0;
3766 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3767 switch(decotype)
3768 {
3769 case -2: break; //nothing
3770 case -1:
3771 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3772 break;
3773 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3774 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3775 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3776 }
3777 731740 }
3778
3779 336026 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3780 {
3781 //keep things inside the screen boundaries
3782 336026 bx=vbound(bx, 0, 255);
3783 336026 by=vbound(by, 0, 176);
3784 336026 int32_t fx=vbound(bx, 0, 255);
3785 336026 int32_t fy=vbound(by, 0, 176);
3786 //first things first
3787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336026 times.
336026 if(attack!=wSword)
3788 return;
3789
3790
3/6
✓ Branch 0 taken 336026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336026 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 41590 times.
377616 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3791
3/4
✓ Branch 0 taken 336026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41590 times.
✓ Branch 3 taken 294436 times.
336026 || (attackclk>SWORDTAPFRAME && tapping))
3792 return;
3793
3794 //find out which combo row/column the coordinates are in
3795 336026 bx &= 0xF0;
3796 336026 by &= 0xF0;
3797
3798 336026 int32_t type = COMBOTYPE(bx,by);
3799 336026 int32_t type2 = FFCOMBOTYPE(fx,fy);
3800 336026 int32_t flag = MAPFLAG(bx,by);
3801 336026 int32_t flag2 = MAPCOMBOFLAG(bx,by);
3802 336026 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
3803 336026 int32_t cid = MAPCOMBO(bx,by);
3804 336026 int32_t i = (bx>>4) + by;
3805
3806
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 336018 times.
336026 if(i > 175)
3807 8 return;
3808
3809 336018 bool ignorescreen=false;
3810 336018 bool ignoreffc=false;
3811
3812
2/2
✓ Branch 0 taken 3569 times.
✓ Branch 1 taken 332449 times.
336018 if(get_bit(screengrid, i) != 0)
3813 {
3814 3569 ignorescreen = true;
3815 3569 }
3816
1/2
✓ Branch 0 taken 332449 times.
✗ Branch 1 not taken.
332449 else if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3817 ignorescreen = true;
3818
3819 336018 int32_t current_ffcombo = getFFCAt(fx,fy);
3820
3821
3822
3/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 335960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
336018 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3823 {
3824 335960 ignoreffc = true;
3825 335960 }
3826
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
3827 ignoreffc = true;
3828
3829
3/4
✓ Branch 0 taken 334668 times.
✓ Branch 1 taken 1350 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 334667 times.
670685 if(!isCuttableType(type) &&
3830
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 334335 times.
✓ Branch 2 taken 334667 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 334667 times.
334668 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3831 {
3832 334667 ignorescreen = true;
3833 334667 }
3834
3835
2/4
✓ Branch 0 taken 336018 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336018 times.
672036 if(!isCuttableType(type2) &&
3836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336018 times.
336018 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3837 {
3838 336018 ignoreffc = true;
3839 336018 }
3840
3841 336018 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3842
3843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336018 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336018 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3844 336018 byte skipsecrets = 0;
3845
3846
2/2
✓ Branch 0 taken 334670 times.
✓ Branch 1 taken 1348 times.
336018 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3847 {
3848
1/2
✓ Branch 0 taken 1348 times.
✗ Branch 1 not taken.
1348 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3849 {
3850 1348 skipsecrets = 0;
3851 1348 }
3852 else skipsecrets = 1; ;
3853 1348 }
3854
3855
3/6
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 335615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 403 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
336018 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3856 {
3857
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
403 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3858 {
3859 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3860 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3861 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3862 }
3863
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 400 times.
403 else if(flag == mfARMOS_SECRET)
3864 {
3865 3 s->data[i] = s->secretcombo[sSTAIRS];
3866 3 s->cset[i] = s->secretcset[sSTAIRS];
3867 3 s->sflag[i] = s->secretflag[sSTAIRS];
3868 3 sfx(tmpscr->secretsfx);
3869 3 }
3870
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399 times.
400 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3871 {
3872
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3873 {
3874 4 findentrance(bx,by,mfSWORD+i2,true);
3875 4 }
3876
3877 1 findentrance(bx,by,mfSTRIKE,true);
3878 1 }
3879
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
399 else if(((flag2 >= 16)&&(flag2 <= 31)))
3880 {
3881 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3882 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3883 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3884 }
3885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 else if(flag2 == mfARMOS_SECRET)
3886 {
3887 s->data[i] = s->secretcombo[sSTAIRS];
3888 s->cset[i] = s->secretcset[sSTAIRS];
3889 s->sflag[i] = s->secretflag[sSTAIRS];
3890 sfx(tmpscr->secretsfx);
3891 }
3892
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399 times.
399 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3893 {
3894 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3895 {
3896 findentrance(bx,by,mfSWORD+i2,true);
3897 }
3898
3899 findentrance(bx,by,mfSTRIKE,true);
3900 }
3901 else
3902 {
3903
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(isCuttableNextType(type))
3904 {
3905 399 s->data[i]++;
3906 399 }
3907 else
3908 {
3909 s->data[i] = s->undercombo;
3910 s->cset[i] = s->undercset;
3911 s->sflag[i] = 0;
3912 }
3913
3914 //pausenow=true;
3915 }
3916 403 }
3917
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 335615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
335615 else if(!ignorescreen && skipsecrets)
3918 {
3919 if(isCuttableNextType(type))
3920 {
3921 s->data[i]++;
3922 }
3923 else
3924 {
3925 s->data[i] = s->undercombo;
3926 s->cset[i] = s->undercset;
3927 s->sflag[i] = 0;
3928 }
3929 }
3930
3931
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336018 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336018 times.
336018 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3932 {
3933 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3934 {
3935 findentrance(bx,by,mfSWORD+i2,true);
3936 }
3937
3938 findentrance(fx,fy,mfSTRIKE,true);
3939 }
3940
1/2
✓ Branch 0 taken 336018 times.
✗ Branch 1 not taken.
336018 else if(!ignoreffc)
3941 {
3942 if(isCuttableNextType(type2))
3943 {
3944 s->ffcs[current_ffcombo].incData(1);
3945 }
3946 else
3947 {
3948 s->ffcs[current_ffcombo].setData(s->undercombo);
3949 s->ffcs[current_ffcombo].cset = s->undercset;
3950 }
3951 }
3952
3953
2/2
✓ Branch 0 taken 335615 times.
✓ Branch 1 taken 403 times.
336018 if(!ignorescreen)
3954 {
3955
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 403 times.
403 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3956
3957
5/8
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 401 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
403 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3958 {
3959
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3960 2 sfx(tmpscr->secretsfx);
3961 2 }
3962
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 398 times.
401 else if(isCuttableItemType(type))
3963 {
3964 398 int32_t it = -1;
3965 398 int32_t thedropset = -1;
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
3967 {
3968 if ( combobuf[cid].usrflags&cflag11 )
3969 {
3970 it = combobuf[cid].attribytes[1];
3971 }
3972 else
3973 {
3974 it = select_dropitem(combobuf[cid].attribytes[1]);
3975 thedropset = combobuf[cid].attribytes[1];
3976 }
3977 }
3978 else
3979 {
3980 398 it = select_dropitem(12);
3981 398 thedropset = 12;
3982 }
3983
3984
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 93 times.
398 if(it!=-1)
3985 {
3986
4/8
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93 times.
✗ Branch 7 not taken.
93 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3987 93 itm->from_dropset = thedropset;
3988 93 items.add(itm);
3989 93 }
3990 398 }
3991
3992 403 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
3993
3994
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(get_bit(quest_rules,qr_MORESOUNDS))
3995 {
3996 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3997 {
3998 if (combobuf[cid].usrflags&cflag3)
3999 {
4000 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4001 }
4002 }
4003 else
4004 {
4005 if (combobuf[cid].usrflags&cflag3)
4006 {
4007 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4008 }
4009 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4010 }
4011 }
4012
4013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
403 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4014
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(decotype > 3) decotype = 0;
4015
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 321 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 321 times.
✓ Branch 6 taken 318 times.
✓ Branch 7 taken 3 times.
403 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4016
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 318 times.
403 switch(decotype)
4017 {
4018 3 case -2: break; //nothing
4019 case -1:
4020 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4021 break;
4022
3/6
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 82 times.
✗ Branch 5 not taken.
82 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4023 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4024
3/6
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 318 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 318 times.
✗ Branch 5 not taken.
318 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4025 }
4026 403 }
4027
4028
1/2
✓ Branch 0 taken 336018 times.
✗ Branch 1 not taken.
336018 if(!ignoreffc)
4029 {
4030 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4031
4032 if(isCuttableItemType(type2))
4033 {
4034 int32_t it=-1;
4035 int32_t thedropset=-1;
4036 if ( (combobuf[cid].usrflags&cflag2) )
4037 {
4038 if(combobuf[cid].usrflags&cflag11)
4039 it = combobuf[cid].attribytes[1];
4040 else
4041 {
4042 it = select_dropitem(combobuf[cid].attribytes[1]);
4043 thedropset = combobuf[cid].attribytes[1];
4044 }
4045 }
4046 else
4047 {
4048 int32_t r=zc_oldrand()%100;
4049
4050 if(r<15)
4051 {
4052 it=iHeart; // 15%
4053 }
4054 else if(r<35)
4055 {
4056 it=iRupy; // 20%
4057 }
4058 }
4059
4060 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4061 {
4062 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4063 itm->from_dropset = thedropset;
4064 items.add(itm);
4065 }
4066 }
4067
4068 if(get_bit(quest_rules,qr_MORESOUNDS))
4069 {
4070 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4071 {
4072 if (combobuf[cid].usrflags&cflag3)
4073 {
4074 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4075 }
4076 }
4077 else
4078 {
4079 if (combobuf[cid].usrflags&cflag3)
4080 {
4081 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4082 }
4083 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4084 }
4085 }
4086
4087 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4088 if(decotype > 3) decotype = 0;
4089 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4090 switch(decotype)
4091 {
4092 case -2: break; //nothing
4093 case -1:
4094 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4095 break;
4096 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4097 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4098 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4099 }
4100 }
4101 336026 }
4102
4103 3949344 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4104 {
4105 /*
4106 int32_t par_item = w->parentitem;
4107 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4108 int32_t usewpn = -1;
4109 if ( par_item > -1 )
4110 {
4111 usewpn = itemsbuf[par_item].useweapon;
4112 }
4113 else if ( par_item == -1 && w->ScriptGenerated )
4114 {
4115 usewpn = w->useweapon;
4116 }
4117 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4118
4119 */
4120 3949344 bx=vbound(bx, 0, 255);
4121 3949344 by=vbound(by, 0, 176);
4122 3949344 int32_t cid = MAPCOMBO(bx,by);
4123
1/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 3949344 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
3949344 switch(w->useweapon)
4124 {
4125 case wArrow:
4126 findentrance(bx,by,mfARROW,true);
4127 findentrance(bx,by,mfSARROW,true);
4128 findentrance(bx,by,mfGARROW,true);
4129 break;
4130 case wBeam:
4131 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4132 break;
4133 case wHookshot:
4134 findentrance(bx,by,mfHOOKSHOT,true);
4135 break;
4136 case wBrang:
4137 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4138 break;
4139 case wMagic:
4140 findentrance(bx,by,mfWANDMAGIC,true);
4141 break;
4142 case wRefMagic:
4143 findentrance(bx,by,mfWANDMAGIC,true);
4144 break;
4145 case wRefBeam:
4146 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4147 break;
4148 //reflected magic needs to happen in mirrors:
4149 //
4150 //findentrance(bx,by,mfREFMAGIC,true)
4151 case wRefFireball:
4152 findentrance(bx,by,mfREFFIREBALL,true);
4153 break;
4154 case wBomb:
4155 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4156 break;
4157
4158 case wSBomb:
4159 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4160 break;
4161
4162 case wFire:
4163 findentrance(bx,by,mfBCANDLE,true);
4164 findentrance(bx,by,mfRCANDLE,true);
4165 findentrance(bx,by,mfWANDFIRE,true);
4166 /* if we want the weapon to die
4167 if (findentrance(bx,by,mfBCANDLE,true) ) dead = 1;
4168 if (findentrance(bx,by,mfRCANDLE,true) ) dead = 1;
4169 if (findentrance(bx,by,mfWANDFIRE,true)) dead = 1;
4170 */
4171 break;
4172
4173 case wScript1:
4174 break;
4175 case wScript2:
4176 break;
4177 case wScript3:
4178 break;
4179 case wScript4:
4180 break;
4181 case wScript5:
4182 break;
4183 case wScript6:
4184 break;
4185 case wScript7:
4186 break;
4187 case wScript8:
4188 break;
4189 case wScript9:
4190 break;
4191 case wScript10:
4192 break;
4193 case wIce:
4194 break;
4195 case wCByrna:
4196 break;
4197 case wWhistle:
4198 break;
4199 case wSSparkle:
4200 case wFSparkle:
4201 break;
4202 case wWind:
4203 break;
4204 case wBait:
4205 break;
4206 case wFlame:
4207 case wThrown:
4208 case wBombos:
4209 case wEther:
4210 case wQuake:
4211 case wSwordLA:
4212 case wSword180:
4213 case wStomp:
4214 break;
4215 case wSword:
4216 case wWand:
4217 //case wCandle:
4218 case wHSHandle:
4219 case wLitBomb:
4220 case wLitSBomb:
4221 break;
4222 3949344 default: break;
4223
4224 }
4225 3949344 }
4226
4227 7898688 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4228 {
4229
4230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7898688 times.
7898688 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4231 {
4232 //zprint("bit off\n");
4233 7898688 return;
4234 }
4235 //keep things inside the screen boundaries
4236 bx=vbound(bx, 0, 255);
4237 by=vbound(by, 0, 176);
4238 int32_t fx=vbound(bx, 0, 255);
4239 int32_t fy=vbound(by, 0, 176);
4240 //first things first
4241 if(w->useweapon != wSword)
4242 return;
4243
4244 //find out which combo row/column the coordinates are in
4245 bx &= 0xF0;
4246 by &= 0xF0;
4247
4248
4249 int32_t flag = MAPFLAGL(layer,bx,by);
4250 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4251 int32_t cid = MAPCOMBOL(layer,bx,by);
4252 int32_t type = combobuf[cid].type;
4253 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4254 type = cNONE;
4255 //zprint("cid is: %d\n", cid);
4256 //zprint("type is: %d\n", type);
4257 int32_t i = (bx>>4) + by;
4258
4259 if(i > 175)
4260 return;
4261
4262 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4263 {
4264 return;
4265 //ignorescreen = true;
4266 //zprint("ignoring\n");
4267 }
4268
4269 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4270
4271 {
4272 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4273 if(isCuttableNextType(type) || isCuttableNextType(type))
4274 {
4275 FFCore.tempScreens[layer]->data[i]++;
4276 }
4277 else
4278 {
4279 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4280 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4281 FFCore.tempScreens[layer]->sflag[i] = 0;
4282 }
4283 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4284 {
4285 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4286 sfx(tmpscr->secretsfx);
4287 }
4288 else if(isCuttableItemType(type))
4289 {
4290 int32_t it = -1;
4291 int32_t thedropset = -1;
4292
4293 if ( (combobuf[cid].usrflags&cflag2) )
4294 {
4295 if(combobuf[cid].usrflags&cflag11)
4296 it = combobuf[cid].attribytes[1];
4297 else
4298 {
4299 it = select_dropitem(combobuf[cid].attribytes[1]);
4300 thedropset = combobuf[cid].attribytes[1];
4301 }
4302 }
4303 else
4304 {
4305 it = select_dropitem(12);
4306 thedropset = 12;
4307 }
4308
4309 if(it!=-1)
4310 {
4311 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4312 itm->from_dropset = thedropset;
4313 items.add(itm);
4314 }
4315 }
4316
4317 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4318
4319 if(get_bit(quest_rules,qr_MORESOUNDS))
4320 {
4321 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4322 {
4323 if (combobuf[cid].usrflags&cflag3)
4324 {
4325 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4326 }
4327 }
4328 else
4329 {
4330 if (combobuf[cid].usrflags&cflag3)
4331 {
4332 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4333 }
4334 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4335 }
4336 }
4337
4338 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4339 if(decotype > 3) decotype = 0;
4340 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4341 switch(decotype)
4342 {
4343 case -2: break; //nothing
4344 case -1:
4345 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4346 break;
4347 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4348 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4349 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4350 }
4351
4352 }
4353
4354 7898688 }
4355
4356 3949344 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4357 {
4358 /*
4359 int32_t par_item = w->parentitem;
4360 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4361 int32_t usewpn = -1;
4362 if ( par_item > -1 )
4363 {
4364 usewpn = itemsbuf[par_item].useweapon;
4365 }
4366 else if ( par_item == -1 && w->ScriptGenerated )
4367 {
4368 usewpn = w->useweapon;
4369 }
4370 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4371 */
4372
4373
4374 //keep things inside the screen boundaries
4375 3949344 bx=vbound(bx, 0, 255);
4376 3949344 by=vbound(by, 0, 176);
4377 3949344 int32_t fx=vbound(bx, 0, 255);
4378 3949344 int32_t fy=vbound(by, 0, 176);
4379 3949344 int32_t cid = MAPCOMBO(bx,by);
4380
4381 //find out which combo row/column the coordinates are in
4382 3949344 bx &= 0xF0;
4383 3949344 by &= 0xF0;
4384
4385 3949344 int32_t type = COMBOTYPE(bx,by);
4386 3949344 int32_t type2 = FFCOMBOTYPE(fx,fy);
4387 3949344 int32_t flag = MAPFLAG(bx,by);
4388 3949344 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4389 3949344 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4390
1/2
✓ Branch 0 taken 3949344 times.
✗ Branch 1 not taken.
3949344 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4391 type = cNONE;
4392 3949344 byte dontignore = 0;
4393 3949344 byte dontignoreffc = 0;
4394
4395
3/4
✓ Branch 0 taken 140274 times.
✓ Branch 1 taken 3809070 times.
✓ Branch 2 taken 140274 times.
✗ Branch 3 not taken.
3949344 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4396 {
4397 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4398 dontignore = 1;
4399 }
4400
4401 /*to-do, ffcs
4402 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4403 {
4404 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4405 dontignoreffc = 1;
4406 }*/
4407
2/4
✓ Branch 0 taken 3949344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3949344 times.
✗ Branch 3 not taken.
3949344 if(w->useweapon != wSword && !dontignore) return;
4408
4409
4410 int32_t i = (bx>>4) + by;
4411 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4412
4413 if(i > 175)
4414 return;
4415
4416 bool ignorescreen=false;
4417 bool ignoreffc=false;
4418
4419 if(get_bit(w->wscreengrid, i) != 0)
4420 {
4421 ignorescreen = true; dontignore = 0;
4422 }
4423
4424 int32_t current_ffcombo = getFFCAt(fx,fy);
4425
4426 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4427 {
4428 ignoreffc = true;
4429 }
4430 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4431 type2 = cNONE;
4432 if(!isCuttableType(type) &&
4433 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4434 {
4435 ignorescreen = true;
4436 }
4437
4438 if(!isCuttableType(type2) &&
4439 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4440 {
4441 ignoreffc = true;
4442 }
4443
4444 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4445
4446 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4447 byte skipsecrets = 0;
4448 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4449 {
4450 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4451 {
4452 skipsecrets = 0;
4453 }
4454 else skipsecrets = 1;
4455 }
4456 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4457 {
4458 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4459 {
4460 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4461 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4462 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4463 }
4464 else if(flag == mfARMOS_SECRET)
4465 {
4466 s->data[i] = s->secretcombo[sSTAIRS];
4467 s->cset[i] = s->secretcset[sSTAIRS];
4468 s->sflag[i] = s->secretflag[sSTAIRS];
4469 sfx(tmpscr->secretsfx);
4470 }
4471 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4472 {
4473 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4474 {
4475 findentrance(bx,by,mfSWORD+i2,true);
4476 }
4477
4478 findentrance(bx,by,mfSTRIKE,true);
4479 }
4480 else if(((flag2 >= 16)&&(flag2 <= 31)))
4481 {
4482 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4483 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4484 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4485 }
4486 else if(flag2 == mfARMOS_SECRET)
4487 {
4488 s->data[i] = s->secretcombo[sSTAIRS];
4489 s->cset[i] = s->secretcset[sSTAIRS];
4490 s->sflag[i] = s->secretflag[sSTAIRS];
4491 sfx(tmpscr->secretsfx);
4492 }
4493 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4494 {
4495 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4496 {
4497 findentrance(bx,by,mfSWORD+i2,true);
4498 }
4499
4500 findentrance(bx,by,mfSTRIKE,true);
4501 }
4502 else
4503 {
4504 if(isCuttableNextType(type))
4505 {
4506 s->data[i]++;
4507 }
4508 else
4509 {
4510 s->data[i] = s->undercombo;
4511 s->cset[i] = s->undercset;
4512 s->sflag[i] = 0;
4513 }
4514
4515 //pausenow=true;
4516 }
4517 }
4518 else if(skipsecrets && (!ignorescreen || dontignore))
4519 {
4520 if(isCuttableNextType(type))
4521 {
4522 s->data[i]++;
4523 }
4524 else
4525 {
4526 s->data[i] = s->undercombo;
4527 s->cset[i] = s->undercset;
4528 s->sflag[i] = 0;
4529 }
4530 }
4531
4532 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4533 {
4534 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4535 {
4536 findentrance(bx,by,mfSWORD+i2,true);
4537 }
4538
4539 findentrance(fx,fy,mfSTRIKE,true);
4540 }
4541 else if(!ignoreffc)
4542 {
4543 if(isCuttableNextType(type2))
4544 {
4545 s->ffcs[current_ffcombo].incData(1);
4546 }
4547 else
4548 {
4549 s->ffcs[current_ffcombo].setData(s->undercombo);
4550 s->ffcs[current_ffcombo].cset = s->undercset;
4551 }
4552 }
4553
4554 if(!ignorescreen || dontignore)
4555 {
4556 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4557
4558 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4559 {
4560 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4561 sfx(tmpscr->secretsfx);
4562 }
4563 else if(isCuttableItemType(type))
4564 {
4565 int32_t it = -1;
4566 int32_t thedropset = -1;
4567 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4568 {
4569 if ( combobuf[cid].usrflags&cflag11 )
4570 {
4571 it = combobuf[cid].attribytes[1];
4572 }
4573 else
4574 {
4575 it = select_dropitem(combobuf[cid].attribytes[1]);
4576 thedropset = combobuf[cid].attribytes[1];
4577 }
4578 }
4579 else
4580 {
4581 it = select_dropitem(12);
4582 thedropset = 12;
4583 }
4584
4585 if(it!=-1)
4586 {
4587 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4588 itm->from_dropset = thedropset;
4589 items.add(itm);
4590 }
4591 }
4592
4593
4594 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4595
4596 if(get_bit(quest_rules,qr_MORESOUNDS))
4597 {
4598 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4599 {
4600 if (combobuf[cid].usrflags&cflag3)
4601 {
4602 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4603 }
4604 }
4605 else
4606 {
4607 if (combobuf[cid].usrflags&cflag3)
4608 {
4609 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4610 }
4611 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4612 }
4613 }
4614
4615 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4616 if(decotype > 3) decotype = 0;
4617 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4618 switch(decotype)
4619 {
4620 case -2: break; //nothing
4621 case -1:
4622 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4623 break;
4624 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4625 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4626 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4627 }
4628 }
4629
4630 if(!ignoreffc)
4631 {
4632 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4633
4634 if(isCuttableItemType(type2))
4635 {
4636 int32_t it=-1;
4637 int32_t thedropset=-1;
4638 if ( (combobuf[cid].usrflags&cflag2) )
4639 {
4640 if(combobuf[cid].usrflags&cflag11)
4641 it = combobuf[cid].attribytes[1];
4642 else
4643 {
4644 it = select_dropitem(combobuf[cid].attribytes[1]);
4645 thedropset = combobuf[cid].attribytes[1];
4646 }
4647 }
4648 else
4649 {
4650 int32_t r=zc_oldrand()%100;
4651
4652 if(r<15)
4653 {
4654 it=iHeart; // 15%
4655 }
4656 else if(r<35)
4657 {
4658 it=iRupy; // 20%
4659 }
4660 }
4661
4662 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4663 {
4664 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4665 itm->from_dropset = thedropset;
4666 items.add(itm);
4667 }
4668 }
4669
4670 if(get_bit(quest_rules,qr_MORESOUNDS))
4671 {
4672 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4673 {
4674 if (combobuf[cid].usrflags&cflag3)
4675 {
4676 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4677 }
4678 }
4679 else
4680 {
4681 if (combobuf[cid].usrflags&cflag3)
4682 {
4683 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4684 }
4685 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4686 }
4687 }
4688
4689 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4690 if(decotype > 3) decotype = 0;
4691 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4692 switch(decotype)
4693 {
4694 case -2: break; //nothing
4695 case -1:
4696 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4697 break;
4698 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4699 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4700 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4701 }
4702 }
4703 3949344 }
4704
4705 3949344 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4706 {
4707 /*
4708 int32_t par_item = w->parentitem;
4709 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4710 int32_t usewpn = -1;
4711 if ( par_item > -1 )
4712 {
4713 usewpn = itemsbuf[par_item].useweapon;
4714 }
4715 else if ( par_item == -1 && w->ScriptGenerated )
4716 {
4717 usewpn = w->useweapon;
4718 }
4719 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4720 */
4721
4722 3949344 byte dontignore = 0;
4723 3949344 byte dontignoreffc = 0;
4724
4725
4726
4727
4728
4729 //keep things inside the screen boundaries
4730 3949344 bx=vbound(bx, 0, 255);
4731 3949344 by=vbound(by, 0, 176);
4732 3949344 int32_t fx=vbound(bx, 0, 255);
4733 3949344 int32_t fy=vbound(by, 0, 176);
4734 3949344 int32_t cid = MAPCOMBO(bx,by);
4735
4736 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4737
2/4
✓ Branch 0 taken 3949344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3949344 times.
3949344 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4738 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4739
4740 //first things first
4741 if(z>8||fakez>8) return;
4742
4743 //find out which combo row/column the coordinates are in
4744 bx &= 0xF0;
4745 by &= 0xF0;
4746
4747 int32_t flag = MAPFLAG(bx,by);
4748 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4749 int32_t flag3=0;
4750 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4751 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4752 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4753 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4754
4755 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4756 flag3=mfWAND;
4757
4758 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4759 flag3=mfSTRIKE;
4760
4761 int32_t i = (bx>>4) + by;
4762
4763 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4764 return;
4765
4766 if(i > 175)
4767 return;
4768
4769 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4770
4771 //findentrance(bx,by,mfWAND,true);
4772 //findentrance(bx,by,mfSTRIKE,true);
4773 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4774 {
4775 if(flag3==mfWAND||flag3==mfSTRIKE)
4776 {
4777 findentrance(fx,fy,mfWAND,true);
4778 findentrance(fx,fy,mfSTRIKE,true);
4779 }
4780 }
4781
4782 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4783
4784 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4785 3949344 }
4786
4787 3949344 void HeroClass::check_pound_block2(int32_t bx, int32_t by, weapon *w)
4788 {
4789 /*
4790 int32_t par_item = w->parentitem;
4791 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
4792 int32_t usewpn = -1;
4793 if ( par_item > -1 )
4794 {
4795 usewpn = itemsbuf[par_item].useweapon;
4796 }
4797 else if ( par_item == -1 && w->ScriptGenerated )
4798 {
4799 usewpn = w->useweapon;
4800 }
4801 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
4802 */
4803 //keep things inside the screen boundaries
4804 3949344 bx=vbound(bx, 0, 255);
4805 3949344 by=vbound(by, 0, 176);
4806 3949344 int32_t fx=vbound(bx, 0, 255);
4807 3949344 int32_t fy=vbound(by, 0, 176);
4808 3949344 int32_t cid = MAPCOMBO(bx,by);
4809 3949344 byte dontignore = MatchComboTrigger (w, combobuf, cid);
4810
2/4
✓ Branch 0 taken 3949344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3949344 times.
3949344 if(w->useweapon != wHammer && !dontignore ) return;
4811
4812
4813
4814
4815 //first things first
4816 if(z>8||fakez>8) return;
4817
4818 //find out which combo row/column the coordinates are in
4819 bx &= 0xF0;
4820 by &= 0xF0;
4821
4822 int32_t type = COMBOTYPE(bx,by);
4823 int32_t type2 = FFCOMBOTYPE(fx,fy);
4824 int32_t flag = MAPFLAG(bx,by);
4825 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4826 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4827 int32_t i = (bx>>4) + by;
4828 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4829
4830 if(i > 175)
4831 return;
4832
4833 bool ignorescreen=false;
4834 bool ignoreffc=false;
4835 bool pound=false;
4836
4837 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4838 type = cNONE;
4839 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
4840 ignorescreen = true; // Affect only FFCs
4841
4842 if(get_bit(w->wscreengrid, i) != 0)
4843 {
4844 ignorescreen = true; dontignore = 0;
4845 }
4846
4847 int32_t current_ffcombo = getFFCAt(fx,fy);
4848
4849 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4850 ignoreffc = true;
4851 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4852 type2 = cNONE;
4853 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
4854 ignoreffc = true;
4855
4856 if(ignorescreen && ignoreffc) // Nothing to do.
4857 return;
4858
4859 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4860
4861 if(!ignorescreen || dontignore)
4862 {
4863 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
4864 {
4865 findentrance(bx,by,mfHAMMER,true);
4866 findentrance(bx,by,mfSTRIKE,true);
4867 }
4868 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
4869 {
4870 findentrance(bx,by,mfHAMMER,true);
4871 findentrance(bx,by,mfSTRIKE,true);
4872 }
4873 else if((flag >= 16)&&(flag <= 31))
4874 {
4875 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4876 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4877 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4878 }
4879 else if(flag == mfARMOS_SECRET)
4880 {
4881 s->data[i] = s->secretcombo[sSTAIRS];
4882 s->cset[i] = s->secretcset[sSTAIRS];
4883 s->sflag[i] = s->secretflag[sSTAIRS];
4884 sfx(tmpscr->secretsfx);
4885 }
4886 else if((flag2 >= 16)&&(flag2 <= 31))
4887 {
4888 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4889 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4890 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4891 }
4892 else if(flag2 == mfARMOS_SECRET)
4893 {
4894 s->data[i] = s->secretcombo[sSTAIRS];
4895 s->cset[i] = s->secretcset[sSTAIRS];
4896 s->sflag[i] = s->secretflag[sSTAIRS];
4897 sfx(tmpscr->secretsfx);
4898 }
4899 else pound = true;
4900 }
4901
4902 if(!ignoreffc)
4903 {
4904 if(flag3==mfHAMMER||flag3==mfSTRIKE)
4905 {
4906 findentrance(fx,fy,mfHAMMER,true);
4907 findentrance(fx,fy,mfSTRIKE,true);
4908 }
4909 else
4910 {
4911 s->ffcs[current_ffcombo].incData(1);
4912 }
4913 }
4914
4915 if(!ignorescreen || dontignore)
4916 {
4917 if(pound)
4918 s->data[i]+=1;
4919
4920 set_bit(w->wscreengrid,i,1);
4921
4922 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4923 {
4924 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4925 sfx(tmpscr->secretsfx);
4926 }
4927
4928 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4929 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4930
4931 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4932 }
4933
4934 if(!ignoreffc)
4935 {
4936 set_bit(ffcgrid,current_ffcombo,1);
4937
4938 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4939 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4940 }
4941
4942 return;
4943 3949344 }
4944
4945 void HeroClass::check_slash_block(weapon *w)
4946 {
4947 //first things
4948
4949 int32_t par_item = w->parentitem;
4950 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4951 int32_t usewpn = -1;
4952 if ( par_item > -1 )
4953 {
4954 usewpn = itemsbuf[par_item].useweapon;
4955 }
4956 else if ( par_item == -1 && w->ScriptGenerated )
4957 {
4958 usewpn = w->useweapon;
4959 }
4960 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4961 if(usewpn != wSword) return;
4962
4963
4964 int32_t bx = 0, by = 0;
4965 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4966 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4967 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4968 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4969 //keep things inside the screen boundaries
4970 bx=vbound(bx, 0, 255);
4971 by=vbound(by, 0, 176);
4972 int32_t fx=vbound(bx, 0, 255);
4973 int32_t fy=vbound(by, 0, 176);
4974
4975 int32_t cid = MAPCOMBO(bx,by);
4976
4977 //find out which combo row/column the coordinates are in
4978 bx &= 0xF0;
4979 by &= 0xF0;
4980
4981 int32_t type = COMBOTYPE(bx,by);
4982 int32_t type2 = FFCOMBOTYPE(fx,fy);
4983 int32_t flag = MAPFLAG(bx,by);
4984 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4985 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4986 int32_t i = (bx>>4) + by;
4987
4988 if(i > 175)
4989 {
4990 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4991 return;
4992 }
4993
4994 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4995 type = cNONE;
4996 bool ignorescreen=false;
4997 bool ignoreffc=false;
4998
4999 if(get_bit(screengrid, i) != 0)
5000 {
5001 ignorescreen = true;
5002 }
5003
5004 int32_t current_ffcombo = getFFCAt(fx,fy);
5005
5006 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5007 {
5008 ignoreffc = true;
5009 }
5010 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
5011 type2 = cNONE;
5012 if(!isCuttableType(type) &&
5013 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5014 {
5015 ignorescreen = true;
5016 }
5017
5018 if(!isCuttableType(type2) &&
5019 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5020 {
5021 ignoreffc = true;
5022 }
5023
5024 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5025
5026 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5027
5028 if(!ignorescreen)
5029 {
5030 if((flag >= 16)&&(flag <= 31))
5031 {
5032 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5033 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5034 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5035 }
5036 else if(flag == mfARMOS_SECRET)
5037 {
5038 s->data[i] = s->secretcombo[sSTAIRS];
5039 s->cset[i] = s->secretcset[sSTAIRS];
5040 s->sflag[i] = s->secretflag[sSTAIRS];
5041 sfx(tmpscr->secretsfx);
5042 }
5043 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5044 {
5045 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5046 {
5047 findentrance(bx,by,mfSWORD+i2,true);
5048 }
5049
5050 findentrance(bx,by,mfSTRIKE,true);
5051 }
5052 else if(((flag2 >= 16)&&(flag2 <= 31)))
5053 {
5054 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5055 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5056 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5057 }
5058 else if(flag2 == mfARMOS_SECRET)
5059 {
5060 s->data[i] = s->secretcombo[sSTAIRS];
5061 s->cset[i] = s->secretcset[sSTAIRS];
5062 s->sflag[i] = s->secretflag[sSTAIRS];
5063 sfx(tmpscr->secretsfx);
5064 }
5065 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5066 {
5067 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5068 {
5069 findentrance(bx,by,mfSWORD+i2,true);
5070 }
5071
5072 findentrance(bx,by,mfSTRIKE,true);
5073 }
5074 else
5075 {
5076 if(isCuttableNextType(type))
5077 {
5078 s->data[i]++;
5079 }
5080 else
5081 {
5082 s->data[i] = s->undercombo;
5083 s->cset[i] = s->undercset;
5084 s->sflag[i] = 0;
5085 }
5086
5087 //pausenow=true;
5088 }
5089 }
5090
5091 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5092 {
5093 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5094 {
5095 findentrance(bx,by,mfSWORD+i2,true);
5096 }
5097
5098 findentrance(fx,fy,mfSTRIKE,true);
5099 }
5100 else if(!ignoreffc)
5101 {
5102 if(isCuttableNextType(type2))
5103 {
5104 s->ffcs[current_ffcombo].incData(1);
5105 }
5106 else
5107 {
5108 s->ffcs[current_ffcombo].setData(s->undercombo);
5109 s->ffcs[current_ffcombo].cset = s->undercset;
5110 }
5111 }
5112
5113 if(!ignorescreen)
5114 {
5115 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5116
5117 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5118 {
5119 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5120 sfx(tmpscr->secretsfx);
5121 }
5122 else if(isCuttableItemType(type))
5123 {
5124 int32_t it = -1;
5125 int32_t thedropset = -1;
5126 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5127 {
5128 if ( combobuf[cid].usrflags&cflag11 )
5129 {
5130 it = combobuf[cid].attribytes[1];
5131 }
5132 else
5133 {
5134 it = select_dropitem(combobuf[cid].attribytes[1]);
5135 thedropset = combobuf[cid].attribytes[1];
5136 }
5137 }
5138 else
5139 {
5140 it = select_dropitem(12);
5141 thedropset = 12;
5142 }
5143
5144 if(it!=-1)
5145 {
5146 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5147 itm->from_dropset = thedropset;
5148 items.add(itm);
5149 }
5150 }
5151
5152 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5153
5154 if(get_bit(quest_rules,qr_MORESOUNDS))
5155 {
5156 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5157 {
5158 if (combobuf[cid].usrflags&cflag3)
5159 {
5160 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5161 }
5162 }
5163 else
5164 {
5165 if (combobuf[cid].usrflags&cflag3)
5166 {
5167 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5168 }
5169 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5170 }
5171 }
5172
5173 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5174 if(decotype > 3) decotype = 0;
5175 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5176 switch(decotype)
5177 {
5178 case -2: break; //nothing
5179 case -1:
5180 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5181 break;
5182 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5183 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5184 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5185 }
5186 }
5187
5188 if(!ignoreffc)
5189 {
5190 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5191
5192 if(isCuttableItemType(type2))
5193 {
5194 int32_t it=-1;
5195 int32_t thedropset = -1;
5196 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5197 {
5198 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5199 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5200 else
5201 {
5202 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5203 it = select_dropitem(thedropset);
5204 }
5205 }
5206 else
5207 {
5208 it = select_dropitem(12);
5209 thedropset = 12;
5210 }
5211
5212 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5213 {
5214 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5215 itm->from_dropset = thedropset;
5216 items.add(itm);
5217 }
5218 }
5219
5220 if(get_bit(quest_rules,qr_MORESOUNDS))
5221 {
5222 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5223 {
5224 if (combobuf[cid].usrflags&cflag3)
5225 {
5226 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5227 }
5228 }
5229 else
5230 {
5231 if (combobuf[cid].usrflags&cflag3)
5232 {
5233 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5234 }
5235 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5236 }
5237 }
5238
5239 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5240 if(decotype > 3) decotype = 0;
5241 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5242 switch(decotype)
5243 {
5244 case -2: break; //nothing
5245 case -1:
5246 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5247 break;
5248 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5249 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5250 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5251 }
5252 }
5253 }
5254
5255 //TODO: Boomerang that cuts bushes. -L
5256 /*void HeroClass::slash_bush()
5257 {
5258
5259 }*/
5260
5261 6222 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5262 {
5263 //keep things inside the screen boundaries
5264 6222 bx=vbound(bx, 0, 255);
5265 6222 by=vbound(by, 0, 176);
5266 6222 int32_t fx=vbound(bx, 0, 255);
5267 6222 int32_t fy=vbound(by, 0, 176);
5268 6222 int32_t cid = MAPCOMBO(bx,by);
5269
5270 //first things first
5271
2/4
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6222 times.
6222 if(z>8||fakez>8) return;
5272
5273 //find out which combo row/column the coordinates are in
5274 6222 bx &= 0xF0;
5275 6222 by &= 0xF0;
5276
5277 6222 int32_t flag = MAPFLAG(bx,by);
5278 6222 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5279 6222 int32_t flag3=0;
5280 6222 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5281 6222 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5282 6222 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5283 6222 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5284
5285
4/8
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6222 times.
6222 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5286 flag3=mfWAND;
5287
5288
4/8
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6222 times.
6222 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5289 flag3=mfSTRIKE;
5290
5291 6222 int32_t i = (bx>>4) + by;
5292
5293
6/12
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6222 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6222 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6222 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6222 times.
✗ Branch 11 not taken.
6222 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5294 6222 return;
5295
5296 if(i > 175)
5297 return;
5298
5299 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5300
5301 //findentrance(bx,by,mfWAND,true);
5302 //findentrance(bx,by,mfSTRIKE,true);
5303 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5304 {
5305 if(flag3==mfWAND||flag3==mfSTRIKE)
5306 {
5307 findentrance(fx,fy,mfWAND,true);
5308 findentrance(fx,fy,mfSTRIKE,true);
5309 }
5310 }
5311
5312 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5313 6222 }
5314
5315 void HeroClass::check_pound_block(int32_t bx, int32_t by)
5316 {
5317 //keep things inside the screen boundaries
5318 bx=vbound(bx, 0, 255);
5319 by=vbound(by, 0, 176);
5320 int32_t fx=vbound(bx, 0, 255);
5321 int32_t fy=vbound(by, 0, 176);
5322 int32_t cid = MAPCOMBO(bx,by);
5323
5324 //first things first
5325 if(z>8||fakez>8) return;
5326
5327 //find out which combo row/column the coordinates are in
5328 bx &= 0xF0;
5329 by &= 0xF0;
5330
5331 int32_t type = COMBOTYPE(bx,by);
5332 int32_t type2 = FFCOMBOTYPE(fx,fy);
5333 int32_t flag = MAPFLAG(bx,by);
5334 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5335 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5336 int32_t i = (bx>>4) + by;
5337
5338 if(i > 175)
5339 return;
5340
5341 bool ignorescreen=false;
5342 bool ignoreffc=false;
5343 bool pound=false;
5344
5345 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5346 ignorescreen = true; // Affect only FFCs
5347
5348 if(get_bit(screengrid, i) != 0)
5349 ignorescreen = true;
5350
5351 int32_t current_ffcombo = getFFCAt(fx,fy);
5352
5353 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5354 ignoreffc = true;
5355
5356 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5357 ignoreffc = true;
5358
5359 if(ignorescreen && ignoreffc) // Nothing to do.
5360 return;
5361
5362 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5363
5364 if(!ignorescreen)
5365 {
5366 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5367 {
5368 findentrance(bx,by,mfHAMMER,true);
5369 findentrance(bx,by,mfSTRIKE,true);
5370 }
5371 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5372 {
5373 findentrance(bx,by,mfHAMMER,true);
5374 findentrance(bx,by,mfSTRIKE,true);
5375 }
5376 else if((flag >= 16)&&(flag <= 31))
5377 {
5378 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5379 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5380 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5381 }
5382 else if(flag == mfARMOS_SECRET)
5383 {
5384 s->data[i] = s->secretcombo[sSTAIRS];
5385 s->cset[i] = s->secretcset[sSTAIRS];
5386 s->sflag[i] = s->secretflag[sSTAIRS];
5387 sfx(tmpscr->secretsfx);
5388 }
5389 else if((flag2 >= 16)&&(flag2 <= 31))
5390 {
5391 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5392 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5393 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5394 }
5395 else if(flag2 == mfARMOS_SECRET)
5396 {
5397 s->data[i] = s->secretcombo[sSTAIRS];
5398 s->cset[i] = s->secretcset[sSTAIRS];
5399 s->sflag[i] = s->secretflag[sSTAIRS];
5400 sfx(tmpscr->secretsfx);
5401 }
5402 else pound = true;
5403 }
5404
5405 if(!ignoreffc)
5406 {
5407 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5408 {
5409 findentrance(fx,fy,mfHAMMER,true);
5410 findentrance(fx,fy,mfSTRIKE,true);
5411 }
5412 else
5413 {
5414 s->ffcs[current_ffcombo].incData(1);
5415 }
5416 }
5417
5418 if(!ignorescreen)
5419 {
5420 if(pound)
5421 s->data[i]+=1;
5422
5423 set_bit(screengrid,i,1);
5424
5425 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5426 {
5427 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5428 sfx(tmpscr->secretsfx);
5429 }
5430
5431 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5432 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5433
5434 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5435 }
5436
5437 if(!ignoreffc)
5438 {
5439 set_bit(ffcgrid,current_ffcombo,1);
5440
5441 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5442 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5443 }
5444
5445 return;
5446 }
5447
5448
5449 void HeroClass::check_wand_block(weapon *w)
5450 {
5451
5452 int32_t par_item = w->parentitem;
5453 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5454 int32_t usewpn = -1;
5455 if ( par_item > -1 )
5456 {
5457 usewpn = itemsbuf[par_item].useweapon;
5458 }
5459 else if ( par_item == -1 && w->ScriptGenerated )
5460 {
5461 usewpn = w->useweapon;
5462 }
5463 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5464 if(usewpn != wWand) return;
5465
5466
5467 int32_t bx = 0, by = 0;
5468 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5469 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5470
5471 //keep things inside the screen boundaries
5472 bx=vbound(bx, 0, 255);
5473 by=vbound(by, 0, 176);
5474 int32_t fx=vbound(bx, 0, 255);
5475 int32_t fy=vbound(by, 0, 176);
5476 int32_t cid = MAPCOMBO(bx,by);
5477 //first things first
5478 if(z>8||fakez>8) return;
5479
5480 //find out which combo row/column the coordinates are in
5481 bx &= 0xF0;
5482 by &= 0xF0;
5483
5484 int32_t flag = MAPFLAG(bx,by);
5485 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5486 int32_t flag3=0;
5487 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5488 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5489 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5490 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5491
5492 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5493 flag3=mfWAND;
5494
5495 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5496 flag3=mfSTRIKE;
5497
5498 int32_t i = (bx>>4) + by;
5499
5500 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5501 return;
5502
5503 if(i > 175)
5504 return;
5505
5506 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5507
5508 //findentrance(bx,by,mfWAND,true);
5509 //findentrance(bx,by,mfSTRIKE,true);
5510 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5511 {
5512 if(flag3==mfWAND||flag3==mfSTRIKE)
5513 {
5514 findentrance(fx,fy,mfWAND,true);
5515 findentrance(fx,fy,mfSTRIKE,true);
5516 }
5517 }
5518
5519 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5520 }
5521
5522 void HeroClass::check_pound_block(weapon *w)
5523 {
5524
5525 int32_t par_item = w->parentitem;
5526 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
5527 int32_t usewpn = -1;
5528 if ( par_item > -1 )
5529 {
5530 usewpn = itemsbuf[par_item].useweapon;
5531 }
5532 else if ( par_item == -1 && w->ScriptGenerated )
5533 {
5534 usewpn = w->useweapon;
5535 }
5536 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
5537 if(usewpn != wHammer) return;
5538
5539
5540 int32_t bx = 0, by = 0;
5541 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5542 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5543 //keep things inside the screen boundaries
5544 bx=vbound(bx, 0, 255);
5545 by=vbound(by, 0, 176);
5546 int32_t fx=vbound(bx, 0, 255);
5547 int32_t fy=vbound(by, 0, 176);
5548 int32_t cid = MAPCOMBO(bx,by);
5549 //first things first
5550 if(z>8||fakez>8) return;
5551
5552 //find out which combo row/column the coordinates are in
5553 bx &= 0xF0;
5554 by &= 0xF0;
5555
5556 int32_t type = COMBOTYPE(bx,by);
5557 int32_t type2 = FFCOMBOTYPE(fx,fy);
5558 int32_t flag = MAPFLAG(bx,by);
5559 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5560 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5561 int32_t i = (bx>>4) + by;
5562
5563 if(i > 175)
5564 return;
5565
5566 bool ignorescreen=false;
5567 bool ignoreffc=false;
5568 bool pound=false;
5569
5570 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5571 ignorescreen = true; // Affect only FFCs
5572
5573 if(get_bit(screengrid, i) != 0)
5574 ignorescreen = true;
5575
5576 int32_t current_ffcombo = getFFCAt(fx,fy);
5577
5578 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5579 ignoreffc = true;
5580
5581 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5582 ignoreffc = true;
5583
5584 if(ignorescreen && ignoreffc) // Nothing to do.
5585 return;
5586
5587 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5588
5589 if(!ignorescreen)
5590 {
5591 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5592 {
5593 findentrance(bx,by,mfHAMMER,true);
5594 findentrance(bx,by,mfSTRIKE,true);
5595 }
5596 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5597 {
5598 findentrance(bx,by,mfHAMMER,true);
5599 findentrance(bx,by,mfSTRIKE,true);
5600 }
5601 else if((flag >= 16)&&(flag <= 31))
5602 {
5603 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5604 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5605 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5606 }
5607 else if(flag == mfARMOS_SECRET)
5608 {
5609 s->data[i] = s->secretcombo[sSTAIRS];
5610 s->cset[i] = s->secretcset[sSTAIRS];
5611 s->sflag[i] = s->secretflag[sSTAIRS];
5612 sfx(tmpscr->secretsfx);
5613 }
5614 else if((flag2 >= 16)&&(flag2 <= 31))
5615 {
5616 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5617 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5618 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5619 }
5620 else if(flag2 == mfARMOS_SECRET)
5621 {
5622 s->data[i] = s->secretcombo[sSTAIRS];
5623 s->cset[i] = s->secretcset[sSTAIRS];
5624 s->sflag[i] = s->secretflag[sSTAIRS];
5625 sfx(tmpscr->secretsfx);
5626 }
5627 else pound = true;
5628 }
5629
5630 if(!ignoreffc)
5631 {
5632 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5633 {
5634 findentrance(fx,fy,mfHAMMER,true);
5635 findentrance(fx,fy,mfSTRIKE,true);
5636 }
5637 else
5638 {
5639 s->ffcs[current_ffcombo].incData(1);
5640 }
5641 }
5642
5643 if(!ignorescreen)
5644 {
5645 if(pound)
5646 s->data[i]+=1;
5647
5648 set_bit(screengrid,i,1);
5649
5650 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5651 {
5652 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5653 sfx(tmpscr->secretsfx);
5654 }
5655
5656 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5657 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5658
5659 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5660 }
5661
5662 if(!ignoreffc)
5663 {
5664 set_bit(ffcgrid,current_ffcombo,1);
5665
5666 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5667 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5668 }
5669
5670 return;
5671 }
5672
5673 //defend results should match defence types.
5674 //RETURN VALUES:
5675 // -1 iGNORE WEAPON
5676 // 0 No effects
5677 // 1 Effects, weapon is not ignored or removed
5678 2641 int32_t HeroClass::defend(weapon *w)
5679 {
5680 2641 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5681
1/25
✓ Branch 0 taken 2641 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
2641 switch(def)
5682 {
5683 2641 case edNORMAL: return 1;
5684 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5685 {
5686 w->power *= 0.5;
5687 return 1;
5688 }
5689 case edQUARTDAMAGE:
5690 {
5691 w->power *= 0.25;
5692 return 1;
5693 }
5694 case edSTUNONLY:
5695 {
5696 setStunClock(120);
5697 return 1;
5698 }
5699 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5700 {
5701 if (w->power > 0)
5702 {
5703 setStunClock(120);
5704 return 1;
5705 }
5706 else
5707 {
5708 sfx(WAV_CHINK,pan(int32_t(x)));
5709 w->dead = 0;
5710 return -1;
5711 }
5712 }
5713 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5714 {
5715 if (w->power > 0)
5716 {
5717 setStunClock(120);
5718 return 1;
5719 }
5720 else
5721 {
5722 return -1;
5723 }
5724 }
5725 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5726 {
5727 if (w->power < 1)
5728 {
5729 sfx(WAV_CHINK,pan(int32_t(x)));
5730 w->dead = 0;
5731 return -1;
5732 }
5733 else
5734 {
5735 return 1;
5736 }
5737 }
5738 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5739 {
5740 if (w->power < 2)
5741 {
5742 sfx(WAV_CHINK,pan(int32_t(x)));
5743 w->dead = 0;
5744 return -1;
5745 }
5746 else
5747 {
5748 return 1;
5749 }
5750 }
5751 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5752 {
5753 if (w->power < 4)
5754 {
5755 sfx(WAV_CHINK,pan(int32_t(x)));
5756 w->dead = 0;
5757 return -1;
5758 }
5759 else
5760 {
5761 return 1;
5762 }
5763 }
5764 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5765 {
5766 if (w->power < 6)
5767 {
5768 sfx(WAV_CHINK,pan(int32_t(x)));
5769 w->dead = 0;
5770 return -1;
5771 }
5772 else
5773 {
5774 return 1;
5775 }
5776 }
5777 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5778 {
5779 if (w->power < 8)
5780 {
5781 sfx(WAV_CHINK,pan(int32_t(x)));
5782 w->dead = 0;
5783 return -1;
5784 }
5785 else
5786 {
5787 return 1;
5788 }
5789 }
5790 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5791 {
5792 sfx(WAV_CHINK,pan(int32_t(x)));
5793 w->dead = 0;
5794 return -1;
5795 }
5796 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5797 {
5798 if (w->power < 1)
5799 {
5800 return -1;
5801 }
5802 else return 1;
5803 }
5804 case edIGNORE: // : IMPLEMENTED : Do Nothing
5805 {
5806 return -1;
5807 }
5808 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5809 {
5810 game->set_life(0);
5811 return 1;
5812 }
5813 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5814 {
5815 if (w->power < 10)
5816 {
5817 sfx(WAV_CHINK,pan(int32_t(x)));
5818 w->dead = 0;
5819 return -1;
5820 }
5821 else
5822 {
5823 return 1;
5824 }
5825 }
5826 case ed2x: // : IMPLEMENTED : Double damage.
5827 {
5828 w->power *= 2;
5829 return 1;
5830 }
5831 case ed3x: // : IMPLEMENTED : Triple Damage.
5832 {
5833 w->power *= 3;
5834 return 1;
5835 }
5836 case ed4x: // : IMPLEMENTED : 4x damage.
5837 {
5838 w->power *= 4;
5839 return 1;
5840 }
5841 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5842 {
5843 //sfx(WAV_HEAL,pan(int32_t(x)));
5844 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5845 w->dead = 0;
5846 return -1;
5847 }
5848
5849 case edFREEZE: return 1; //Not IMPLEMENTED
5850
5851 case edLEVELDAMAGE: //Damage * item level
5852 {
5853 w->power *= w->family_level;
5854 return 1;
5855 }
5856 case edLEVELREDUCTION: //Damage / item level
5857 {
5858 if ( w->family_level > 0 )
5859 {
5860 w->power /= w->family_level;
5861 }
5862 else w->power = 0;
5863 return 1;
5864 }
5865
5866 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5867 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5868 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5869 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5870
5871 //edSHOCK, //buzz blob
5872
5873
5874 case edBREAKSHIELD: //destroy the player's present shield
5875 {
5876 w->power = 0;
5877 w->dead = 0;
5878 int32_t itemid = getCurrentShield();
5879 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5880 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5881 game->set_item(itemid, false);
5882 //Remove Hero's shield
5883 return -1;
5884 }
5885
5886
5887
5888 default: return 0;
5889 }
5890 2641 }
5891
5892 2637 int32_t HeroClass::compareDir(int32_t other)
5893 {
5894
3/6
✓ Branch 0 taken 2637 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2637 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2637 times.
2637 if(other != NORMAL_DIR(other))
5895 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5896 2637 int32_t ret = 0;
5897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2637 times.
2637 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5898
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 441 times.
✓ Branch 3 taken 881 times.
✓ Branch 4 taken 835 times.
2637 switch(d)
5899 {
5900 case up:
5901 {
5902
3/3
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 191 times.
✓ Branch 2 taken 186 times.
480 switch(X_DIR(other))
5903 {
5904 case left:
5905 191 ret |= CMPDIR_RIGHT;
5906 191 break;
5907 case right:
5908 186 ret |= CMPDIR_LEFT;
5909 186 break;
5910 }
5911
3/3
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 333 times.
480 switch(Y_DIR(other))
5912 {
5913 case up:
5914 110 ret |= CMPDIR_BACK;
5915 110 break;
5916 case down:
5917 333 ret |= CMPDIR_FRONT;
5918 333 break;
5919 }
5920 480 break;
5921 }
5922 case down:
5923 {
5924
3/3
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 203 times.
441 switch(X_DIR(other))
5925 {
5926 case left:
5927 144 ret |= CMPDIR_LEFT;
5928 144 break;
5929 case right:
5930 203 ret |= CMPDIR_RIGHT;
5931 203 break;
5932 }
5933
3/3
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 83 times.
441 switch(Y_DIR(other))
5934 {
5935 case up:
5936 306 ret |= CMPDIR_FRONT;
5937 306 break;
5938 case down:
5939 83 ret |= CMPDIR_BACK;
5940 83 break;
5941 }
5942 441 break;
5943 }
5944 case left:
5945 {
5946
3/3
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 723 times.
881 switch(X_DIR(other))
5947 {
5948 case left:
5949 127 ret |= CMPDIR_BACK;
5950 127 break;
5951 case right:
5952 723 ret |= CMPDIR_FRONT;
5953 723 break;
5954 }
5955
3/3
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 298 times.
✓ Branch 2 taken 290 times.
881 switch(Y_DIR(other))
5956 {
5957 case up:
5958 298 ret |= CMPDIR_LEFT;
5959 298 break;
5960 case down:
5961 290 ret |= CMPDIR_RIGHT;
5962 290 break;
5963 }
5964 881 break;
5965 }
5966 case right:
5967 {
5968
3/3
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 697 times.
✓ Branch 2 taken 116 times.
835 switch(X_DIR(other))
5969 {
5970 case left:
5971 697 ret |= CMPDIR_FRONT;
5972 697 break;
5973 case right:
5974 116 ret |= CMPDIR_BACK;
5975 116 break;
5976 }
5977
3/3
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 346 times.
835 switch(Y_DIR(other))
5978 {
5979 case up:
5980 242 ret |= CMPDIR_RIGHT;
5981 242 break;
5982 case down:
5983 346 ret |= CMPDIR_LEFT;
5984 346 break;
5985 }
5986 835 break;
5987 }
5988 }
5989 2637 return ret;
5990 2637 }
5991
5992 2637 bool compareShield(int32_t cmpdir, itemdata const& shield)
5993 {
5994
1/2
✓ Branch 0 taken 2637 times.
✗ Branch 1 not taken.
2637 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5995
1/2
✓ Branch 0 taken 2637 times.
✗ Branch 1 not taken.
2637 if(standard) //Use standard sides, either a passive shield, or a held active shield
5996 {
5997
3/4
✓ Branch 0 taken 2059 times.
✓ Branch 1 taken 578 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059 times.
2637 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5998 2059 return true;
5999
3/4
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
578 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
6000 return true;
6001
3/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 258 times.
✗ Branch 3 not taken.
578 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
6002 return true;
6003
3/4
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 279 times.
578 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
6004 return true;
6005 578 }
6006 else //Active Shield that is NOT held down
6007 {
6008 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
6009 return true;
6010 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
6011 return true;
6012 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
6013 return true;
6014 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
6015 return true;
6016 }
6017 578 return false;
6018 2637 }
6019
6020 1767602 int32_t HeroClass::EwpnHit()
6021 {
6022
2/2
✓ Branch 0 taken 1766529 times.
✓ Branch 1 taken 1875897 times.
3642426 for(int32_t i=0; i<Ewpns.Count(); i++)
6023 {
6024
2/2
✓ Branch 0 taken 1873256 times.
✓ Branch 1 taken 2641 times.
1875897 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6025 {
6026 2641 weapon *ew = (weapon*)(Ewpns.spr(i));
6027
6028
3/6
✓ Branch 0 taken 2641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2641 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2641 times.
2641 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6029 break;
6030
6031 2641 int32_t defresult = defend(ew);
6032
1/2
✓ Branch 0 taken 2641 times.
✗ Branch 1 not taken.
2641 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6033
6034
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 1 times.
2641 if(ew->id==ewWind)
6035 {
6036 1 xofs=1000;
6037 1 action=freeze; FFCore.setHeroAction(freeze);
6038 1 ew->misc=999; // in enemy wind
6039 1 attackclk=0;
6040 1 return -1;
6041 }
6042
6043
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2637 times.
2640 switch(ew->id)
6044 {
6045 case ewLitBomb:
6046 case ewBomb:
6047 case ewLitSBomb:
6048 case ewSBomb:
6049 3 return i;
6050 }
6051
6052 2637 int32_t itemid = getCurrentShield(false);
6053
3/6
✓ Branch 0 taken 2637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2637 times.
2637 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6054 2637 itemdata const& shield = itemsbuf[itemid];
6055 2637 auto cmpdir = compareDir(ew->dir);
6056 2637 bool hitshield = compareShield(cmpdir, shield);
6057
6058
6059
11/18
✓ Branch 0 taken 2059 times.
✓ Branch 1 taken 578 times.
✓ Branch 2 taken 1676 times.
✓ Branch 3 taken 383 times.
✓ Branch 4 taken 1676 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1676 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1676 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1676 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1676 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1676 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1676 times.
2637 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF)
6060 {
6061 961 return i;
6062 }
6063
6064 1676 paymagiccost(itemid);
6065
6066 1676 bool reflect = false;
6067
6068
7/8
✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 77 times.
✓ Branch 7 taken 55 times.
1676 switch(ew->id)
6069 {
6070 case ewFireball2:
6071 case ewFireball:
6072
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 1068 times.
1120 if(ew->type & 1) //Boss fireball
6073 {
6074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(!(shield.misc1 & (shFIREBALL2)))
6075 52 return i;
6076
6077 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6078 }
6079 else
6080 {
6081
2/2
✓ Branch 0 taken 1033 times.
✓ Branch 1 taken 35 times.
1068 if(!(shield.misc1 & (shFIREBALL)))
6082 35 return i;
6083
6084 1033 reflect = ((shield.misc2 & shFIREBALL) != 0);
6085 }
6086
6087 1033 break;
6088
6089 case ewMagic:
6090
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1 times.
138 if(!(shield.misc1 & shMAGIC))
6091 1 return i;
6092
6093 137 reflect = ((shield.misc2 & shMAGIC) != 0);
6094 137 break;
6095
6096 case ewSword:
6097
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1 times.
129 if(!(shield.misc1 & shSWORD))
6098 1 return i;
6099
6100 128 reflect = ((shield.misc2 & shSWORD) != 0);
6101 128 break;
6102
6103 case ewFlame:
6104
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 19 times.
49 if(!(shield.misc1 & shFLAME))
6105 19 return i;
6106
6107 30 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6108 30 break;
6109
6110 case ewRock:
6111
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!(shield.misc1 & shROCK))
6112 return i;
6113
6114 108 reflect = (shield.misc2 & shROCK);
6115 108 break;
6116
6117 case ewArrow:
6118
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!(shield.misc1 & shARROW))
6119 return i;
6120
6121 77 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6122 77 break;
6123
6124 case ewBrang:
6125
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!(shield.misc1 & shBRANG))
6126 return i;
6127
6128 55 break;
6129
6130 default: // Just throw the script weapons in here...
6131 if(ew->id>=wScript1 && ew->id<=wScript10)
6132 {
6133 if(!(shield.misc1 & shSCRIPT))
6134 return i;
6135
6136 reflect = ((shield.misc2 & shSCRIPT) != 0);
6137 }
6138
6139 break;
6140 }
6141
6142
3/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 1406 times.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
1568 if(reflect && (ew->unblockable&WPNUNB_REFL))
6143 reflect = false;
6144
3/4
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 1406 times.
✗ Branch 3 not taken.
1568 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6145 return i;
6146
6147 1568 int32_t oldid = ew->id;
6148 1568 ew->onhit(false, reflect ? 2 : 1, dir);
6149
6150
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 162 times.
1568 if(ew->id != oldid) // changed type from ewX to wX
6151 {
6152 // ew->power*=game->get_hero_dmgmult();
6153 162 Lwpns.add(ew);
6154 162 Ewpns.remove(ew);
6155 162 ew->isLWeapon = true; //Make sure this gets set everywhere!
6156 162 }
6157
6158
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 36 times.
1568 if(ew->id==wRefMagic)
6159 {
6160 36 ew->ignoreHero=true;
6161 36 ew->ignorecombo=-1;
6162 36 }
6163
6164 1568 sfx(shield.usesound,pan(x.getInt()));
6165 1568 }
6166 1874824 }
6167
6168 1766529 return -1;
6169 1767602 }
6170
6171 1767602 int32_t HeroClass::LwpnHit() //only here to check magic hits
6172 {
6173
2/2
✓ Branch 0 taken 1721009 times.
✓ Branch 1 taken 826268 times.
2547277 for(int32_t i=0; i<Lwpns.Count(); i++)
6174
2/2
✓ Branch 0 taken 779675 times.
✓ Branch 1 taken 46593 times.
826268 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6175 {
6176 46593 weapon *lw = (weapon*)(Lwpns.spr(i));
6177
6178
2/2
✓ Branch 0 taken 46057 times.
✓ Branch 1 taken 536 times.
46593 if((lw->ignoreHero)==true)
6179 536 break;
6180
6181
4/8
✓ Branch 0 taken 46057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46057 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46057 times.
46057 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6182 int32_t itemid = getCurrentShield(false);
6183 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6184 itemdata const& shield = itemsbuf[itemid];
6185 auto cmpdir = compareDir(lw->dir);
6186 bool hitshield = compareShield(cmpdir, shield);
6187 bool reflect = false;
6188
6189 switch(lw->id)
6190 {
6191 case wRefFireball:
6192 if(itemid<0)
6193 return i;
6194
6195 if(lw->type & 1) //Boss fireball
6196 return i;
6197
6198 if(!(shield.misc1 & (shFIREBALL)))
6199 return i;
6200
6201 reflect = ((shield.misc2 & shFIREBALL) != 0);
6202 break;
6203
6204 case wRefMagic:
6205 if(itemid<0)
6206 return i;
6207
6208 if(!(shield.misc1 & shMAGIC))
6209 return i;
6210
6211 reflect = ((shield.misc2 & shMAGIC) != 0);
6212 break;
6213
6214 case wRefBeam:
6215 if(itemid<0)
6216 return i;
6217
6218 if(!(shield.misc1 & shSWORD))
6219 return i;
6220
6221 reflect = ((shield.misc2 & shSWORD) != 0);
6222 break;
6223
6224 case wRefRock:
6225 if(itemid<0)
6226 return i;
6227
6228 if(!(shield.misc1 & shROCK))
6229 return i;
6230
6231 reflect = (shield.misc2 & shROCK);
6232 break;
6233
6234 default:
6235 return -1;
6236 }
6237
6238 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || hopclk==0xFF)
6239 return i;
6240
6241 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6242
6243 paymagiccost(itemid);
6244
6245 lw->onhit(false, 1+reflect, dir);
6246 lw->ignoreHero=true;
6247 lw->ignorecombo=-1;
6248 sfx(shield.usesound,pan(x.getInt()));
6249 }
6250
6251 1721545 return -1;
6252 1767602 }
6253
6254 3563570 void HeroClass::checkhit()
6255 {
6256
2/2
✓ Branch 0 taken 1581708 times.
✓ Branch 1 taken 1981862 times.
3563570 if(checkhero==true)
6257 {
6258
2/2
✓ Branch 0 taken 109771 times.
✓ Branch 1 taken 1872091 times.
1981862 if(hclk>0)
6259 {
6260 109771 --hclk;
6261 109771 }
6262
6263
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 if(NayrusLoveShieldClk>0)
6264 {
6265 --NayrusLoveShieldClk;
6266
6267 if(NayrusLoveShieldClk == 0 && nayruitem != -1)
6268 {
6269 stop_sfx(itemsbuf[nayruitem].usesound);
6270 stop_sfx(itemsbuf[nayruitem].usesound+1);
6271 nayruitem = -1;
6272 }
6273 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(NayrusLoveShieldClk&0xF00) && nayruitem != -1)
6274 {
6275 stop_sfx(itemsbuf[nayruitem].usesound);
6276 cont_sfx(itemsbuf[nayruitem].usesound+1);
6277 }
6278 }
6279 1981862 }
6280
6281
4/4
✓ Branch 0 taken 1961144 times.
✓ Branch 1 taken 1602426 times.
✓ Branch 2 taken 1959681 times.
✓ Branch 3 taken 1463 times.
3563570 if(hclk<39 && action==gothit)
6282 {
6283 1463 action=none; FFCore.setHeroAction(none);
6284 1463 }
6285
6286
5/6
✓ Branch 0 taken 1961144 times.
✓ Branch 1 taken 1602426 times.
✓ Branch 2 taken 1961141 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1961141 times.
3563570 if(hclk<39 && (action==swimhit || action == sideswimhit))
6287 {
6288 3 SetSwim();
6289 3 }
6290
6291
4/4
✓ Branch 0 taken 18420 times.
✓ Branch 1 taken 3545150 times.
✓ Branch 2 taken 3392 times.
✓ Branch 3 taken 15028 times.
3563570 if(hclk>=40 && action==gothit)
6292 {
6293 15028 int val = check_pitslide();
6294
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 14878 times.
✓ Branch 2 taken 15084 times.
✓ Branch 3 taken 14934 times.
15028 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6295 {
6296
2/2
✓ Branch 0 taken 60336 times.
✓ Branch 1 taken 15084 times.
75420 for(int32_t i=0; i<4; i++)
6297 {
6298
5/5
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 12412 times.
✓ Branch 2 taken 14960 times.
✓ Branch 3 taken 15676 times.
✓ Branch 4 taken 17224 times.
60336 switch(hitdir)
6299 {
6300 case up:
6301
6/6
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 11774 times.
✓ Branch 2 taken 240 times.
✓ Branch 3 taken 11534 times.
✓ Branch 4 taken 638 times.
✓ Branch 5 taken 11774 times.
12412 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6302 {
6303 638 action=none; FFCore.setHeroAction(none);
6304 638 }
6305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11774 times.
11774 else if (val == -1) --y;
6306
6307 12412 break;
6308
6309 case down:
6310
6/6
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 14019 times.
✓ Branch 2 taken 1008 times.
✓ Branch 3 taken 13011 times.
✓ Branch 4 taken 949 times.
✓ Branch 5 taken 14011 times.
14960 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6311 {
6312 949 action=none; FFCore.setHeroAction(none);
6313 949 }
6314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14011 times.
14011 else if (val == -1) ++y;
6315
6316 14960 break;
6317
6318 case left:
6319
7/8
✓ Branch 0 taken 15246 times.
✓ Branch 1 taken 430 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15246 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 15214 times.
✓ Branch 6 taken 430 times.
✓ Branch 7 taken 15246 times.
15676 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6320 {
6321 430 action=none; FFCore.setHeroAction(none);
6322 430 }
6323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15246 times.
15246 else if (val == -1) --x;
6324
6325 15676 break;
6326
6327 case right:
6328
7/8
✓ Branch 0 taken 16763 times.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16763 times.
✓ Branch 4 taken 16731 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 461 times.
✓ Branch 7 taken 16763 times.
17224 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6329 {
6330 461 action=none; FFCore.setHeroAction(none);
6331 461 }
6332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16763 times.
16763 else if (val == -1) ++x;
6333
6334 17224 break;
6335 }
6336 60336 }
6337 15084 }
6338 15140 }
6339
6340
16/20
✓ Branch 0 taken 1874361 times.
✓ Branch 1 taken 1689321 times.
✓ Branch 2 taken 1874361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1872784 times.
✓ Branch 5 taken 1577 times.
✓ Branch 6 taken 1872632 times.
✓ Branch 7 taken 152 times.
✓ Branch 8 taken 1872632 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1872632 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1872632 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1871160 times.
✓ Branch 15 taken 1472 times.
✓ Branch 16 taken 547 times.
✓ Branch 17 taken 1870613 times.
✓ Branch 18 taken 1797369 times.
✓ Branch 19 taken 1797916 times.
3563682 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6341 {
6342 3489891 return;
6343 }
6344
6345
2/2
✓ Branch 0 taken 2702322 times.
✓ Branch 1 taken 1870589 times.
4572911 for(int32_t i=0; i<Lwpns.Count(); i++)
6346 {
6347 2702322 sprite *s = Lwpns.spr(i);
6348 2702322 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6349 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6350 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6351
13/14
✓ Branch 0 taken 5448 times.
✓ Branch 1 taken 2696874 times.
✓ Branch 2 taken 898958 times.
✓ Branch 3 taken 1797916 times.
✓ Branch 4 taken 898958 times.
✓ Branch 5 taken 898958 times.
✓ Branch 6 taken 896294 times.
✓ Branch 7 taken 2664 times.
✓ Branch 8 taken 896294 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 29683 times.
✓ Branch 11 taken 866611 times.
✓ Branch 12 taken 18892 times.
✓ Branch 13 taken 10791 times.
2702322 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6352 {
6353
7/10
✓ Branch 0 taken 860600 times.
✓ Branch 1 taken 16802 times.
✓ Branch 2 taken 16802 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 16789 times.
✓ Branch 8 taken 877389 times.
✓ Branch 9 taken 13 times.
877415 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6354
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 (itemid < 0 || itemsbuf[itemid].family!=itype_dinsfire))
6355 {
6356 13 std::vector<int32_t> &ev = FFCore.eventData;
6357 13 ev.clear();
6358 13 ev.push_back(lwpn_dp(i)*10000);
6359 13 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6360 13 ev.push_back(0);
6361 13 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6362 13 ev.push_back(48*10000);
6363 13 ev.push_back(ZSD_LWPN*10000);
6364 13 ev.push_back(s->getUID());
6365
6366 13 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6367 13 int32_t dmg = ev[0]/10000;
6368 13 bool nullhit = ev[2] != 0;
6369
6370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(nullhit) {ev.clear(); return;}
6371
6372 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6373 13 ev[0] = ringpower(dmg)*10000;
6374
6375 13 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6376 13 dmg = ev[0]/10000;
6377 13 int32_t hdir = ev[1]/10000;
6378 13 nullhit = ev[2] != 0;
6379 13 bool nayrulove = ev[3] != 0;
6380 13 int32_t iframes = ev[4] / 10000;
6381 13 ev.clear();
6382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(nullhit) return;
6383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!nayrulove)
6384 {
6385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 game->set_life(zc_max(game->get_life()-dmg,0));
6386 13 }
6387
6388 13 hitdir = hdir;
6389
6390
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
13 if (action != rafting && action != freeze && action != sideswimfreeze)
6391 {
6392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (IsSideSwim())
6393 {
6394 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6395 }
6396
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 else if (action == swimming || hopclk == 0xFF)
6397 {
6398 action=swimhit; FFCore.setHeroAction(swimhit);
6399 }
6400 else
6401 {
6402 13 action=gothit; FFCore.setHeroAction(gothit);
6403 }
6404 13 }
6405
6406
5/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
13 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6407 {
6408 3 spins = charging = attackclk = 0;
6409 3 attack=none;
6410 3 tapping = false;
6411 3 }
6412
6413 13 hclk=iframes;
6414 13 sfx(getHurtSFX(),pan(x.getInt()));
6415 13 return;
6416 }
6417 877389 }
6418
6419 // check enemy weapons true, 1, -1
6420 //
6421
1/2
✓ Branch 0 taken 904393 times.
✗ Branch 1 not taken.
904393 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6422 {
6423 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6424 {
6425 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6426 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6427 itemid = vbound(itemid, 0, MAXITEMS-1);
6428
6429 for(int32_t j=0; j<Ewpns.Count(); j++)
6430 {
6431 sprite *t = Ewpns.spr(j);
6432
6433 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6434 {
6435 bool reflect = false;
6436 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6437 switch(t->id)
6438 {
6439 case ewBrang:
6440 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6441
6442 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6443 goto killweapon;
6444
6445 case ewArrow:
6446 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6447
6448 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6449 goto killweapon;
6450
6451 case ewRock:
6452 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6453
6454 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6455 goto killweapon;
6456
6457 case ewFireball2:
6458 case ewFireball:
6459 {
6460 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6461
6462 if(!(itemsbuf[itemid].misc3 & mask)) break;
6463
6464 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6465 goto killweapon;
6466 }
6467
6468 case ewSword:
6469 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6470
6471 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6472 goto killweapon;
6473
6474 case wRefMagic:
6475 case ewMagic:
6476 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6477
6478 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6479 goto killweapon;
6480
6481 case wScript1:
6482 case wScript2:
6483 case wScript3:
6484 case wScript4:
6485 case wScript5:
6486 case wScript6:
6487 case wScript7:
6488 case wScript8:
6489 case wScript9:
6490 case wScript10:
6491 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6492
6493 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6494 goto killweapon;
6495
6496 case ewLitBomb:
6497 case ewLitSBomb:
6498 killweapon:
6499 ((weapon*)s)->dead=1;
6500 weapon *ew = ((weapon*)t);
6501 int32_t oldid = ew->id;
6502 ew->onhit(true, reflect ? 2 : 1, s->dir);
6503
6504 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6505 {
6506 Lwpns.add(ew);
6507 Ewpns.remove(ew);
6508 ew->isLWeapon = true; //Make sure this gets set everywhere!
6509 }
6510
6511 if(ew->id==wRefMagic)
6512 {
6513 ew->ignoreHero=true;
6514 ew->ignorecombo=-1;
6515 }
6516
6517 break;
6518 }
6519
6520 break;
6521 }
6522 }
6523 }
6524 }
6525
6526
5/6
✓ Branch 0 taken 553745 times.
✓ Branch 1 taken 350648 times.
✓ Branch 2 taken 5448 times.
✓ Branch 3 taken 548297 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5448 times.
904393 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6527 {
6528
2/10
✓ Branch 0 taken 350648 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 350648 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
350648 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6529 {
6530 std::vector<int32_t> &ev = FFCore.eventData;
6531 ev.clear();
6532 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6533 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6534 ev.push_back(0);
6535 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6536 ev.push_back(48*10000);
6537 ev.push_back(ZSD_LWPN*10000);
6538 ev.push_back(s->getUID());
6539
6540 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6541 int32_t dmg = ev[0]/10000;
6542 bool nullhit = ev[2] != 0;
6543
6544 if(nullhit) {ev.clear(); return;}
6545
6546 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6547 ev[0] = ringpower(dmg)*10000;
6548
6549 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6550 dmg = ev[0]/10000;
6551 int32_t hdir = ev[1]/10000;
6552 nullhit = ev[2] != 0;
6553 bool nayrulove = ev[3] != 0;
6554 int32_t iframes = ev[4] / 10000;
6555 ev.clear();
6556 if(nullhit) return;
6557 if(!nayrulove)
6558 {
6559 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6560 }
6561
6562 hitdir = hdir;
6563
6564 if (action != rafting && action != freeze && action != sideswimfreeze)
6565 {
6566 if (IsSideSwim())
6567 {
6568 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6569 }
6570 else if (action == swimming || hopclk == 0xFF)
6571 {
6572 action=swimhit; FFCore.setHeroAction(swimhit);
6573 }
6574 else
6575 {
6576 action=gothit; FFCore.setHeroAction(gothit);
6577 }
6578 }
6579
6580 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6581 {
6582 spins = charging = attackclk = 0;
6583 attack=none;
6584 tapping = false;
6585 }
6586
6587 hclk=iframes;
6588 sfx(getHurtSFX(),pan(x.getInt()));
6589 return;
6590 }
6591 350648 }
6592
6593
7/8
✓ Branch 0 taken 904393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 959 times.
✓ Branch 3 taken 903434 times.
✓ Branch 4 taken 948 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 904382 times.
✓ Branch 7 taken 11 times.
904393 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6594 {
6595 11 std::vector<int32_t> &ev = FFCore.eventData;
6596 11 ev.clear();
6597 11 ev.push_back(0);
6598 11 ev.push_back(s->dir*10000);
6599 11 ev.push_back(0);
6600 11 ev.push_back(0);
6601 11 ev.push_back(ZSD_LWPN*10000);
6602 11 ev.push_back(s->getUID());
6603
6604 11 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6605 11 bool nullhit = ev[2] != 0;
6606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(nullhit) {ev.clear(); return;}
6607
6608 11 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6609 11 int32_t hdir = ev[1]/10000;
6610 11 nullhit = ev[2] != 0;
6611 11 ev.clear();
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(nullhit) return;
6613
6614 11 reset_hookshot();
6615 11 xofs=1000;
6616 11 action=inwind; FFCore.setHeroAction(inwind);
6617 11 dir=s->dir=hdir;
6618 11 spins = charging = attackclk = 0;
6619
6620 // In case Hero used two whistles in a row, summoning two whirlwinds,
6621 // check which whistle's whirlwind picked him up so the correct
6622 // warp ring will be used
6623 11 int32_t whistle=((weapon*)s)->parentitem;
6624
6625
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6626 11 whistleitem=whistle;
6627
6628 11 return;
6629 }
6630 904382 }
6631
6632
6/8
✓ Branch 0 taken 1863949 times.
✓ Branch 1 taken 6640 times.
✓ Branch 2 taken 1831920 times.
✓ Branch 3 taken 32029 times.
✓ Branch 4 taken 1831920 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1831920 times.
3702509 if(action==rafting || action==freeze || action==sideswimfreeze ||
6633
4/8
✓ Branch 0 taken 1831920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1831920 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1831920 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1831920 times.
✗ Branch 7 not taken.
1831920 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6634 38669 return;
6635
6636 1831920 int32_t hit2 = -1;
6637 1831920 do
6638 {
6639
2/2
✓ Branch 0 taken 9059 times.
✓ Branch 1 taken 1824601 times.
1833660 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6640 1824601 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6641
6642
2/2
✓ Branch 0 taken 1829042 times.
✓ Branch 1 taken 4618 times.
1833660 if(hit2!=-1)
6643 {
6644
2/2
✓ Branch 0 taken 1740 times.
✓ Branch 1 taken 2878 times.
4618 if (hithero(hit2) == 0) return;
6645 1740 }
6646
2/2
✓ Branch 0 taken 1740 times.
✓ Branch 1 taken 1829042 times.
1830782 } while (hit2 != -1);
6647
5/6
✓ Branch 0 taken 1775803 times.
✓ Branch 1 taken 53239 times.
✓ Branch 2 taken 1767602 times.
✓ Branch 3 taken 8201 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1767602 times.
1829042 if (superman || !(scriptcoldet&1) || fallclk) return;
6648 1767602 hit2 = LwpnHit();
6649
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1767602 times.
1767602 if(hit2!=-1)
6651 {
6652 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6653 std::vector<int32_t> &ev = FFCore.eventData;
6654 ev.clear();
6655 ev.push_back((lwpn_dp(hit2)*10000));
6656 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6657 ev.push_back(0);
6658 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6659 ev.push_back(48*10000);
6660 ev.push_back(ZSD_LWPN*10000);
6661 ev.push_back(lwpnspr->getUID());
6662
6663 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6664 int32_t dmg = ev[0]/10000;
6665 bool nullhit = ev[2] != 0;
6666
6667 if(nullhit) {ev.clear(); return;}
6668
6669 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6670 ev[0] = ringpower(dmg)*10000;
6671
6672 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6673 dmg = ev[0]/10000;
6674 int32_t hdir = ev[1]/10000;
6675 nullhit = ev[2] != 0;
6676 bool nayrulove = ev[3] != 0;
6677 int32_t iframes = ev[4] / 10000;
6678 ev.clear();
6679 if(nullhit) return;
6680 if(!nayrulove)
6681 {
6682 game->set_life(zc_max(game->get_life()-dmg,0));
6683 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6684 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6685 }
6686
6687 hitdir = hdir;
6688 lwpnspr->onhit(false);
6689
6690 if (IsSideSwim())
6691 {
6692 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6693 }
6694 else if(action==swimming || hopclk==0xFF)
6695 {
6696 action=swimhit; FFCore.setHeroAction(swimhit);
6697 }
6698 else
6699 {
6700 action=gothit; FFCore.setHeroAction(gothit);
6701 }
6702
6703 hclk=iframes;
6704
6705 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6706 {
6707 spins = charging = attackclk = 0;
6708 attack=none;
6709 tapping = false;
6710 }
6711
6712 sfx(getHurtSFX(),pan(x.getInt()));
6713 return;
6714 }
6715
6716 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6717
6718 1767602 hit2 = EwpnHit();
6719
6720
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 1766530 times.
1767602 if(hit2!=-1)
6721 {
6722 1072 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6723 1072 std::vector<int32_t> &ev = FFCore.eventData;
6724 1072 ev.clear();
6725 1072 ev.push_back((ewpn_dp(hit2)*10000));
6726 1072 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6727 1072 ev.push_back(0);
6728 1072 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6729 1072 ev.push_back(48*10000);
6730 1072 ev.push_back(ZSD_EWPN*10000);
6731 1072 ev.push_back(ewpnspr->getUID());
6732
6733 1072 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6734 1072 int32_t dmg = ev[0]/10000;
6735 1072 bool nullhit = ev[2] != 0;
6736
6737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
1072 if(nullhit) {ev.clear(); return;}
6738
6739 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6740 1072 ev[0] = ringpower(dmg)*10000;
6741
6742 1072 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6743 1072 dmg = ev[0]/10000;
6744 1072 int32_t hdir = ev[1]/10000;
6745 1072 nullhit = ev[2] != 0;
6746 1072 bool nayrulove = ev[3] != 0;
6747 1072 int32_t iframes = ev[4] / 10000;
6748 1072 ev.clear();
6749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
1072 if(nullhit) return;
6750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
1072 if(!nayrulove)
6751 {
6752
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 1 times.
1072 game->set_life(zc_max(game->get_life()-dmg,0));
6753 1072 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6754 1072 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6755 1072 }
6756
6757 1072 hitdir = hdir;
6758 1072 ewpnspr->onhit(false);
6759
6760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
1072 if (IsSideSwim())
6761 {
6762 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6763 }
6764
3/4
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1071 times.
1072 else if(action==swimming || hopclk==0xFF)
6765 {
6766 1 action=swimhit; FFCore.setHeroAction(swimhit);
6767 1 }
6768 else
6769 {
6770 1071 action=gothit; FFCore.setHeroAction(gothit);
6771 }
6772
6773 1072 hclk=iframes;
6774
6775
5/8
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 263 times.
✓ Branch 5 taken 809 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 263 times.
1072 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6776 {
6777 809 spins = charging = attackclk = 0;
6778 809 attack=none;
6779 809 tapping = false;
6780 809 }
6781
6782 1072 sfx(getHurtSFX(),pan(x.getInt()));
6783 1072 return;
6784 }
6785 //else { sethitHeroUID(HIT_BY_EWEAPON,(0)); } //fails to clear
6786
6787 // The rest of this method deals with damage combos, which can be jumped over.
6788
2/4
✓ Branch 0 taken 1766530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1766530 times.
✗ Branch 3 not taken.
1766530 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6789
6790 1766530 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6791 1766530 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1766530 times.
1766530 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1766530 times.
1766530 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6794
6795
2/2
✓ Branch 0 taken 1766530 times.
✓ Branch 1 taken 2808024 times.
4574554 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6796 2808024 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6797 1981862 }
6798
6799 21 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6800 {
6801 21 return checkdamagecombos(dx,dx,dy,dy);
6802 }
6803
6804 19 void HeroClass::doHit(int32_t hdir)
6805 {
6806 19 hitdir = hdir;
6807
6808
3/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 19 times.
19 if (action != rafting && action != freeze && action != sideswimfreeze)
6809 {
6810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (IsSideSwim())
6811 {
6812 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6813 }
6814
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
19 else if (action == swimming || hopclk == 0xFF)
6815 {
6816 action=swimhit; FFCore.setHeroAction(swimhit);
6817 }
6818 else
6819 {
6820 19 action=gothit; FFCore.setHeroAction(gothit);
6821 }
6822 19 }
6823
6824 19 hclk=48;
6825
6826
5/8
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8 times.
19 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6827 {
6828 11 spins = charging = attackclk = 0;
6829 11 attack=none;
6830 11 tapping = false;
6831 11 }
6832
6833 19 sfx(getHurtSFX(),pan(x.getInt()));
6834 19 }
6835
6836 2858392 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6837 {
6838
3/6
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2858392 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2858392 times.
2858392 if(hclk || superman || fallclk)
6839 return false;
6840
6841 2858392 int32_t hp_mod[4] = {0};
6842 int32_t cid[8];
6843 2858392 byte hasKB = 0;
6844
6845 {
6846
2/2
✓ Branch 0 taken 1075059 times.
✓ Branch 1 taken 1783333 times.
2858392 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6847 2858392 newcombo& cmb = combobuf[cid[0]];
6848
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2858384 times.
✓ Branch 3 taken 8 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6849 {
6850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(cmb.usrflags&cflag1)
6851 hp_mod[0] = cmb.attributes[0] / -10000L;
6852 else
6853 8 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(cmb.usrflags&cflag2))
6855 8 hasKB |= 1<<0;
6856 8 }
6857 }
6858 {
6859
2/2
✓ Branch 0 taken 1075059 times.
✓ Branch 1 taken 1783333 times.
2858392 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6860 2858392 newcombo& cmb = combobuf[cid[1]];
6861
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2858383 times.
✓ Branch 3 taken 9 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6862 {
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(cmb.usrflags&cflag1)
6864 hp_mod[1] = cmb.attributes[0] / -10000L;
6865 else
6866 9 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(cmb.usrflags&cflag2))
6868 9 hasKB |= 1<<1;
6869 9 }
6870 }
6871 {
6872
2/2
✓ Branch 0 taken 1075059 times.
✓ Branch 1 taken 1783333 times.
2858392 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6873 2858392 newcombo& cmb = combobuf[cid[2]];
6874
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2858381 times.
✓ Branch 3 taken 11 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6875 {
6876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(cmb.usrflags&cflag1)
6877 hp_mod[2] = cmb.attributes[0] / -10000L;
6878 else
6879 11 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!(cmb.usrflags&cflag2))
6881 11 hasKB |= 1<<2;
6882 11 }
6883 }
6884 {
6885
2/2
✓ Branch 0 taken 1075059 times.
✓ Branch 1 taken 1783333 times.
2858392 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6886 2858392 newcombo& cmb = combobuf[cid[3]];
6887
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2858381 times.
✓ Branch 3 taken 11 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6888 {
6889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(cmb.usrflags&cflag1)
6890 hp_mod[3] = cmb.attributes[0] / -10000L;
6891 else
6892 11 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!(cmb.usrflags&cflag2))
6894 11 hasKB |= 1<<3;
6895 11 }
6896 }
6897
6898 2858392 int32_t bestcid=0;
6899 2858392 int32_t hp_modtotal=0;
6900
2/2
✓ Branch 0 taken 2092568 times.
✓ Branch 1 taken 765824 times.
2858392 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6901
2/2
✓ Branch 0 taken 2091452 times.
✓ Branch 1 taken 766940 times.
2858392 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6902
2/2
✓ Branch 0 taken 2092592 times.
✓ Branch 1 taken 765800 times.
2858392 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6903
2/2
✓ Branch 0 taken 2091476 times.
✓ Branch 1 taken 766916 times.
2858392 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6904
6905
2/2
✓ Branch 0 taken 5716784 times.
✓ Branch 1 taken 2858392 times.
8575176 for (int32_t i = 0; i <= 1; ++i)
6906 {
6907
2/2
✓ Branch 0 taken 4777859 times.
✓ Branch 1 taken 938925 times.
5716784 if(tmpscr2[i].valid!=0)
6908 {
6909
2/2
✓ Branch 0 taken 931302 times.
✓ Branch 1 taken 7623 times.
938925 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6910 {
6911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6913
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6915 931302 }
6916 else
6917 {
6918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6919
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6920
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6921
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6922 }
6923 938925 }
6924 5716784 }
6925
6926
2/2
✓ Branch 0 taken 11433568 times.
✓ Branch 1 taken 2858392 times.
14291960 for(int32_t i=0; i<4; i++)
6927 {
6928
2/2
✓ Branch 0 taken 6241536 times.
✓ Branch 1 taken 5192032 times.
11433568 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
6929 {
6930
2/2
✓ Branch 0 taken 6241503 times.
✓ Branch 1 taken 33 times.
6241536 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
6931 {
6932
2/2
✓ Branch 0 taken 6241488 times.
✓ Branch 1 taken 15 times.
6241503 if(hp_mod[i] < hp_modtotal)
6933 {
6934 15 hp_modtotal = hp_mod[i];
6935 15 bestcid = cid[i];
6936 15 }
6937 6241503 }
6938
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 24 times.
33 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
6939 {
6940
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(hp_mod[i] > hp_modtotal)
6941 {
6942 hp_modtotal = hp_mod[i];
6943 bestcid = cid[i];
6944 }
6945 24 }
6946 6241536 }
6947
1/2
✓ Branch 0 taken 5192032 times.
✗ Branch 1 not taken.
5192032 else if(hp_mod[i] < hp_modtotal)
6948 {
6949 hp_modtotal = hp_mod[i];
6950 bestcid = cid[i];
6951 }
6952 11433568 }
6953
6954 {
6955 2858392 cid[4] = MAPFFCOMBO(dx1,dy1);
6956 2858392 newcombo& cmb = combobuf[cid[4]];
6957
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2857993 times.
✓ Branch 3 taken 399 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6958 {
6959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
6960 hp_mod[0] = cmb.attributes[0]/10000L;
6961 else
6962 399 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6963
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
6964 hasKB |= 1<<4;
6965 399 }
6966 }
6967 {
6968 2858392 cid[5] = MAPFFCOMBO(dx1,dy2);
6969 2858392 newcombo& cmb = combobuf[cid[5]];
6970
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2857993 times.
✓ Branch 3 taken 399 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6971 {
6972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
6973 hp_mod[1] = cmb.attributes[0]/10000L;
6974 else
6975 399 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6976
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
6977 hasKB |= 1<<5;
6978 399 }
6979 }
6980 {
6981 2858392 cid[6] = MAPFFCOMBO(dx2,dy1);
6982 2858392 newcombo& cmb = combobuf[cid[6]];
6983
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2857993 times.
✓ Branch 3 taken 399 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6984 {
6985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
6986 hp_mod[2] = cmb.attributes[0]/10000L;
6987 else
6988 399 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6989
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
6990 hasKB |= 1<<6;
6991 399 }
6992 }
6993 {
6994 2858392 cid[7] = MAPFFCOMBO(dx2,dy2);
6995 2858392 newcombo& cmb = combobuf[cid[7]];
6996
3/4
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2857993 times.
✓ Branch 3 taken 399 times.
2858392 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6997 {
6998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
6999 hp_mod[3] = cmb.attributes[0]/10000L;
7000 else
7001 399 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7002
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
7003 hasKB |= 1<<7;
7004 399 }
7005 }
7006
7007 2858392 int32_t bestffccid = 0;
7008 2858392 int32_t hp_modtotalffc = 0;
7009
7010
2/2
✓ Branch 0 taken 5716784 times.
✓ Branch 1 taken 2858392 times.
8575176 for (int32_t i = 0; i <= 1; ++i)
7011 {
7012
2/2
✓ Branch 0 taken 4777859 times.
✓ Branch 1 taken 938925 times.
5716784 if(tmpscr2[i].valid!=0)
7013 {
7014
2/2
✓ Branch 0 taken 931302 times.
✓ Branch 1 taken 7623 times.
938925 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7015 {
7016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931302 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7020 931302 }
7021 else
7022 {
7023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7027 }
7028 938925 }
7029 5716784 }
7030
7031
2/2
✓ Branch 0 taken 11433568 times.
✓ Branch 1 taken 2858392 times.
14291960 for(int32_t i=0; i<4; i++)
7032 {
7033
2/2
✓ Branch 0 taken 6241536 times.
✓ Branch 1 taken 5192032 times.
11433568 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7034 {
7035
2/2
✓ Branch 0 taken 6241503 times.
✓ Branch 1 taken 33 times.
6241536 if(hp_modtotalffc >= 0)
7036 {
7037
2/2
✓ Branch 0 taken 6241488 times.
✓ Branch 1 taken 15 times.
6241503 if(hp_mod[i] < hp_modtotalffc)
7038 {
7039 15 hp_modtotalffc = hp_mod[i];
7040 15 bestffccid = cid[4+i];
7041 15 }
7042 6241503 }
7043
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 24 times.
33 else if(hp_mod[i] < 0)
7044 {
7045
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(hp_mod[i] > hp_modtotalffc)
7046 {
7047 hp_modtotalffc = hp_mod[i];
7048 bestffccid = cid[4+i];
7049 }
7050 24 }
7051 6241536 }
7052
2/2
✓ Branch 0 taken 5191633 times.
✓ Branch 1 taken 399 times.
5192032 else if(hp_mod[i] < hp_modtotalffc)
7053 {
7054 399 hp_modtotalffc = hp_mod[i];
7055 399 bestffccid = cid[4+i];
7056 399 }
7057 11433568 }
7058
7059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2858392 times.
2858392 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7060
1/2
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
2858392 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7061
7062 2858392 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7063 2858392 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7064 2858392 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7065
1/2
✓ Branch 0 taken 2858392 times.
✗ Branch 1 not taken.
2858392 if(current_ring)
7066 {
7067 global_defring = !global_defring;
7068 global_perilring = !global_perilring;
7069 }
7070 2858392 int32_t itemid = current_item_id(itype_boots);
7071
7072
2/2
✓ Branch 0 taken 2808959 times.
✓ Branch 1 taken 49433 times.
2858392 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7073
2/2
✓ Branch 0 taken 2808959 times.
✓ Branch 1 taken 49433 times.
2858392 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7074
7075
2/2
✓ Branch 0 taken 2857978 times.
✓ Branch 1 taken 414 times.
2858392 if(hp_modmin<0)
7076 {
7077
8/14
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 390 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 390 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 390 times.
✓ Branch 10 taken 390 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 390 times.
414 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7078 {
7079
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 if (!do_health_check) return true;
7080 16 std::vector<int32_t> &ev = FFCore.eventData;
7081 16 ev.clear();
7082 16 ev.push_back(-hp_modmin*10000);
7083
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1 times.
16 ev.push_back((hasKB ? dir^1 : -1)*10000);
7084 16 ev.push_back(0);
7085 16 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7086 16 ev.push_back(48*10000);
7087 16 ev.push_back(ZSD_COMBODATA*10000);
7088 16 ev.push_back(bestcid);
7089
7090 16 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7091 16 int32_t dmg = ev[0]/10000;
7092 16 bool nullhit = ev[2] != 0;
7093
7094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(nullhit) {ev.clear(); return false;}
7095
7096 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7097 16 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7098
7099 16 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7100 16 dmg = ev[0]/10000;
7101 16 int32_t hdir = ev[1]/10000;
7102 16 nullhit = ev[2] != 0;
7103 16 bool nayrulove = ev[3] != 0;
7104 16 int32_t iframes = ev[4] / 10000;
7105 16 ev.clear();
7106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(nullhit) return false;
7107
7108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!nayrulove)
7109 {
7110
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1 times.
16 game->set_life(zc_max(game->get_life()-dmg,0));
7111 16 }
7112
7113 16 hitdir = hdir;
7114 16 doHit(hitdir);
7115 16 hclk = iframes;
7116 16 return true;
7117 }
7118
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7119 390 }
7120
7121 2858368 return false;
7122 2858392 }
7123
7124 4651 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7125 {
7126
1/2
✓ Branch 0 taken 4651 times.
✗ Branch 1 not taken.
4651 if(force_hdir > 3) force_hdir = -1;
7127 4651 enemy* enemyptr = (enemy*)guys.spr(hit2);
7128
1/2
✓ Branch 0 taken 4651 times.
✗ Branch 1 not taken.
4651 if(!enemyptr) return 0;
7129 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7130 4651 int32_t stompid = current_item_id(itype_stompboots);
7131
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4651 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7132 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7133 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7134 {
7135 paymagiccost(stompid);
7136 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7137
7138 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7139 game->set_item(stompid,false);
7140
7141 // Stomp Boots script
7142 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7143 {
7144 //clear the item script stack for a new script
7145 ri = &(itemScriptData[stompid]);
7146 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7147 ri->Clear();
7148 //itemScriptData[(stompid & 0xFFF)].Clear();
7149 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7150 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7151 item_doscript[stompid] = 1;
7152 itemscriptInitialised[stompid] = 0;
7153 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7154 }
7155
7156 return -1;
7157 }
7158
5/6
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 2953 times.
✓ Branch 3 taken 239 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2953 times.
4651 else if(superman || !(scriptcoldet&1) || fallclk)
7159 1698 return 0;
7160 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7161 //!Add a flag check to this if:
7162
5/6
✓ Branch 0 taken 1276 times.
✓ Branch 1 taken 1677 times.
✓ Branch 2 taken 1276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 611 times.
✓ Branch 5 taken 665 times.
2953 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7163
3/4
✓ Branch 0 taken 538 times.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1203 times.
1276 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7164 {
7165 1750 return -1;
7166 }
7167
7168 1203 std::vector<int32_t> &ev = FFCore.eventData;
7169 1203 ev.clear();
7170 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7171 1203 ev.push_back((enemy_dp(hit2) *10000));
7172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1203 times.
1203 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7173 1203 ev.push_back(0);
7174 1203 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7175 1203 ev.push_back(48*10000);
7176 1203 ev.push_back(ZSD_NPC*10000);
7177 1203 ev.push_back(enemyptr->getUID());
7178
7179 1203 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7180 1203 int32_t dmg = ev[0] / 10000;
7181 1203 bool nullhit = ev[2] != 0;
7182
7183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1203 times.
1203 if(nullhit) {ev.clear(); return -1;}
7184
7185 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7186 1203 ev[0] = ((ringpower(dmg)*10000));
7187
7188 1203 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7189 1203 dmg = ev[0] / 10000;
7190 1203 int32_t hdir = ev[1] / 10000;
7191 1203 nullhit = ev[2] != 0;
7192 1203 bool nayrulove = ev[3] != 0;
7193 1203 int32_t iframes = ev[4] / 10000;
7194 1203 ev.clear();
7195
7196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1203 times.
1203 if(nullhit) return -1;
7197
7198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1203 times.
1203 if(!nayrulove)
7199 {
7200
2/2
✓ Branch 0 taken 1198 times.
✓ Branch 1 taken 5 times.
1203 game->set_life(zc_max(game->get_life()-dmg,0));
7201 1203 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7202 1203 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7203 1203 }
7204
7205 1203 hitdir = hdir;
7206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1203 times.
1203 if (IsSideSwim())
7207 {
7208 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7209 }
7210
3/4
✓ Branch 0 taken 1201 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1201 times.
1203 else if(action==swimming || hopclk==0xFF)
7211 {
7212 2 action=swimhit; FFCore.setHeroAction(swimhit);
7213 2 }
7214 else
7215 {
7216 1201 action=gothit; FFCore.setHeroAction(gothit);
7217 }
7218
7219 1203 hclk=iframes;
7220 1203 sfx(getHurtSFX(),pan(x.getInt()));
7221
7222
5/8
✓ Branch 0 taken 1203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 357 times.
✓ Branch 5 taken 846 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 357 times.
1203 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7223 {
7224 846 spins = charging = attackclk = 0;
7225 846 attack=none;
7226 846 tapping = false;
7227 846 }
7228
7229 1203 enemy_scored(hit2);
7230 1203 int32_t dm7 = enemyptr->dmisc7;
7231 1203 int32_t dm8 = enemyptr->dmisc8;
7232
7233
2/3
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
1203 switch(enemyptr->family)
7234 {
7235 case eeWALLM:
7236 if(enemyptr->hp>0)
7237 {
7238 GrabHero(hit2);
7239 inwallm=true;
7240 action=none; FFCore.setHeroAction(none);
7241 }
7242 break;
7243
7244 //case eBUBBLEST:
7245 //case eeBUBBLE:
7246 case eeWALK:
7247 {
7248 763 int32_t itemid = current_item_id(itype_whispring);
7249 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7252
7253
4/7
✓ Branch 0 taken 562 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
763 switch(dm7)
7254 {
7255 case e7tTEMPJINX:
7256
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
130 if(dm8==0 || dm8==2)
7257
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
239 if(swordclk>=0 && !(sworddivisor==0))
7258 119 swordclk=150;
7259
7260
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
130 if(dm8==1 || dm8==2)
7261
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
20 if(itemclk>=0 && !(itemdivisor==0))
7262 10 itemclk=150;
7263
7264 130 break;
7265
7266 case e7tPERMJINX:
7267
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
29 if(dm8==0 || dm8==2)
7268
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7269
7270
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
29 if(dm8==1 || dm8==2)
7271
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7272
7273 29 break;
7274
7275 case e7tUNJINX:
7276
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
42 if(dm8==0 || dm8==2)
7277 35 swordclk=0;
7278
7279
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
42 if(dm8==1 || dm8==2)
7280 7 itemclk=0;
7281
7282 42 break;
7283
7284 case e7tTAKEMAGIC:
7285 game->change_dmagic(-dm8*game->get_magicdrainrate());
7286 break;
7287
7288 case e7tTAKERUPEES:
7289 game->change_drupy(-dm8);
7290 break;
7291
7292 case e7tDRUNK:
7293 drunkclk += dm8;
7294 break;
7295 }
7296 763 verifyAWpn();
7297
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 7 times.
763 if(dm7 >= e7tEATITEMS)
7298 {
7299 7 EatHero(hit2);
7300 7 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7301 7 action=none; FFCore.setHeroAction(none);
7302 7 }
7303 }
7304 763 }
7305 1203 return 0;
7306 4651 }
7307
7308 123151 void HeroClass::addsparkle(int32_t wpn)
7309 {
7310 //return;
7311 123151 weapon *w = (weapon*)Lwpns.spr(wpn);
7312 123151 int32_t itemid = w->parentitem;
7313
7314
1/2
✓ Branch 0 taken 123151 times.
✗ Branch 1 not taken.
123151 if(itemid<0)
7315 return;
7316
7317 123151 int32_t itemtype = itemsbuf[itemid].family;
7318
7319
3/4
✓ Branch 0 taken 123151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30794 times.
✓ Branch 3 taken 92357 times.
123151 if(itemtype!=itype_cbyrna && frame%4)
7320 92357 return;
7321
7322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30794 times.
30794 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30794 times.
30794 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7324 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7325
4/8
✓ Branch 0 taken 12626 times.
✓ Branch 1 taken 18168 times.
✓ Branch 2 taken 18168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12626 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
30794 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7326 30794 int32_t direction=w->dir;
7327
7328
2/2
✓ Branch 0 taken 18168 times.
✓ Branch 1 taken 12626 times.
30794 if(sparkle_type)
7329 {
7330 12626 int32_t h=0;
7331 12626 int32_t v=0;
7332
7333
6/6
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 2947 times.
✓ Branch 2 taken 8923 times.
✓ Branch 3 taken 756 times.
✓ Branch 4 taken 1782 times.
✓ Branch 5 taken 7141 times.
12626 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7334 {
7335 5485 h=-1;
7336 5485 }
7337
7338
6/6
✓ Branch 0 taken 9807 times.
✓ Branch 1 taken 2819 times.
✓ Branch 2 taken 8124 times.
✓ Branch 3 taken 1683 times.
✓ Branch 4 taken 945 times.
✓ Branch 5 taken 7179 times.
12626 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7339 {
7340 5447 h=1;
7341 5447 }
7342
7343
6/6
✓ Branch 0 taken 11921 times.
✓ Branch 1 taken 705 times.
✓ Branch 2 taken 10976 times.
✓ Branch 3 taken 945 times.
✓ Branch 4 taken 1782 times.
✓ Branch 5 taken 9194 times.
12626 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7344 {
7345 3432 v=-1;
7346 3432 }
7347
7348
6/6
✓ Branch 0 taken 11637 times.
✓ Branch 1 taken 989 times.
✓ Branch 2 taken 9954 times.
✓ Branch 3 taken 1683 times.
✓ Branch 4 taken 756 times.
✓ Branch 5 taken 9198 times.
12626 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7349 {
7350 3428 v=1;
7351 3428 }
7352
7353 // Damaging boomerang sparkle?
7354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12626 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12626 if(wpn3 && itemtype==itype_brang)
7355 {
7356 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7357 // whatever it just bounced off of if it's shielded from that direction.
7358 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7359 direction=oppositeDir[direction];
7360 }
7361
2/4
✓ Branch 0 taken 12626 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12626 times.
12626 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12626 times.
12626 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12626 times.
12626 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7364
5/10
✓ Branch 0 taken 12626 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12626 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12626 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12626 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12626 times.
✗ Branch 9 not taken.
12626 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7365 12626 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7366 12626 }
7367 123151 }
7368
7369 // For wPhantoms
7370 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7371 {
7372 if(frame%4) return;
7373
7374 int32_t arrow = -1;
7375
7376 for(int32_t i=0; i<Lwpns.Count(); i++)
7377 {
7378 weapon *w = (weapon*)Lwpns.spr(i);
7379
7380 if(w->id == wPhantom && w->type == type1)
7381 {
7382 arrow = i;
7383 break;
7384 }
7385 }
7386
7387 if(arrow==-1)
7388 {
7389 return;
7390 }
7391
7392 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7393 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7394 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7395 }
7396
7397 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7398 1981852 void HeroClass::PhantomsCleanup()
7399 {
7400
1/2
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
1981852 if(Lwpns.idCount(wPhantom))
7401 {
7402 for(int32_t i=0; i<Lwpns.Count(); i++)
7403 {
7404 weapon *w = ((weapon *)Lwpns.spr(i));
7405 if ( w->id == wPhantom && !w->isScriptGenerated() )
7406 {
7407 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7408 {
7409 Lwpns.remove(w);
7410 }
7411 }
7412 }
7413 }
7414 1981852 }
7415
7416 //Waitframe handler for refilling operations
7417 3358 static void do_refill_waitframe()
7418 {
7419 3358 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7420
1/2
✓ Branch 0 taken 3358 times.
✗ Branch 1 not taken.
3358 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7421 {
7422 script_drawing_commands.Clear();
7423 if(DMaps[currdmap].passive_sub_script != 0)
7424 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7425 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7426 {
7427 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7428 passive_subscreen_waitdraw = false;
7429 }
7430 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7431 }
7432 3358 advanceframe(true);
7433 3358 }
7434 //Special handler if it's a "fairy revive"
7435 static void do_death_refill_waitframe()
7436 {
7437 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7438 //This script should be able to draw a 'fairy saving the player' animation -Em
7439 do_refill_waitframe();
7440 }
7441
7442 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7443 {
7444 int32_t found_unowned = -1;
7445 for(int q = 0; q < MAXITEMS; ++q)
7446 {
7447 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7448 {
7449 if(game->get_item(q))
7450 return q;
7451 if(unowned)
7452 found_unowned = q;
7453 }
7454 }
7455 return found_unowned;
7456 }
7457
7458 int32_t getPushDir(int32_t flag)
7459 {
7460 switch(flag)
7461 {
7462 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7463 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7464 case mfPUSHUINS:
7465 return up;
7466 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7467 return down;
7468 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7469 case mfPUSHLRINS: case mfPUSHLINS:
7470 return left;
7471 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7472 return right;
7473 }
7474 return -1;
7475 }
7476
7477 // returns true when game over
7478 5932700 bool HeroClass::animate(int32_t)
7479 {
7480 5932700 int32_t lsave=0;
7481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5932700 times.
5932700 if(immortal > 0)
7482 --immortal;
7483 5932700 prompt_combo = 0;
7484
2/2
✓ Branch 0 taken 3950838 times.
✓ Branch 1 taken 1981862 times.
5932700 if (onpassivedmg)
7485 {
7486 3950838 onpassivedmg=false;
7487 3950838 }
7488
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 else if (damageovertimeclk)
7489 {
7490 damageovertimeclk = 0;
7491 }
7492
7493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5932700 times.
5932700 if(cheats_execute_goto)
7494 {
7495 didpit=true;
7496 pitx=x;
7497 pity=y;
7498 dowarp(3,0);
7499 cheats_execute_goto=false;
7500 solid_update(false);
7501 return false;
7502 }
7503
7504
1/2
✓ Branch 0 taken 5932700 times.
✗ Branch 1 not taken.
5932700 if(cheats_execute_light)
7505 {
7506 naturaldark = !naturaldark;
7507 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7508 cheats_execute_light = false;
7509 }
7510
7511
3/4
✓ Branch 0 taken 1981862 times.
✓ Branch 1 taken 3950838 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1981862 times.
5932700 if(action!=climbcovertop&&action!=climbcoverbottom)
7512 {
7513 1981862 climb_cover_x=-1000;
7514 1981862 climb_cover_y=-1000;
7515 1981862 }
7516
7517
1/2
✓ Branch 0 taken 5932700 times.
✗ Branch 1 not taken.
5932700 if(mirror_portal)
7518 {
7519 mirror_portal->animate(0);
7520 if(abs(x - mirror_portal->x) < 12
7521 && abs(y - mirror_portal->y) < 12)
7522 {
7523 if(can_mirror_portal)
7524 {
7525 //Store some values to restore if 'warp fails'
7526 int32_t tLastEntrance = lastentrance,
7527 tLastEntranceDMap = lastentrance_dmap,
7528 tContScr = game->get_continue_scrn(),
7529 tContDMap = game->get_continue_dmap();
7530 int32_t sourcescr = currscr, sourcedmap = currdmap;
7531 zfix tx = x, ty = y, tz = z;
7532 x = mirror_portal->x;
7533 y = mirror_portal->y;
7534
7535 int32_t weff = mirror_portal->weffect,
7536 wsfx = mirror_portal->wsfx;
7537
7538 FFCore.warp_player(wtIWARP, mirror_portal->destdmap, mirror_portal->destscr,
7539 -1, -1, weff, wsfx, 0, -1);
7540
7541 if(mirrorBonk()) //Invalid landing, warp back!
7542 {
7543 action = none; FFCore.setHeroAction(none);
7544 lastentrance = tLastEntrance;
7545 lastentrance_dmap = tLastEntranceDMap;
7546 game->set_continue_scrn(tContScr);
7547 game->set_continue_dmap(tContDMap);
7548 x = tx;
7549 y = ty;
7550 z = tz;
7551 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7552 wsfx, 0, -1);
7553 can_mirror_portal = false;
7554 }
7555 else game->clear_portal(); //Remove portal once used
7556 }
7557 }
7558 else can_mirror_portal = true;
7559 }
7560
7561
3/4
✓ Branch 0 taken 1981754 times.
✓ Branch 1 taken 3950946 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1981754 times.
5932700 if(z<=8&&fakez<=8)
7562 {
7563
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 1981135 times.
1981754 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7564 {
7565 619 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7567 {
7568
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7569
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7570
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7571
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7572 619 }
7573
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
619 if(g1 && g2 && g3 && g4)
7574 {
7575 if(decorations.idCount(dTALLGRASS)==0)
7576 {
7577 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7578 }
7579 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7580 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7581 sfx(thesfx,pan((int32_t)x));
7582 }
7583 619 }
7584 else
7585 {
7586 1981135 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7587
2/2
✓ Branch 0 taken 8811 times.
✓ Branch 1 taken 1972324 times.
1981135 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7588 {
7589
2/4
✓ Branch 0 taken 8811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8811 times.
8811 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7590
2/4
✓ Branch 0 taken 8811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8811 times.
8811 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7591 8811 }
7592
4/4
✓ Branch 0 taken 25163 times.
✓ Branch 1 taken 1955972 times.
✓ Branch 2 taken 3104 times.
✓ Branch 3 taken 22059 times.
1981135 if(g1 && g2)
7593 {
7594
2/2
✓ Branch 0 taken 21762 times.
✓ Branch 1 taken 297 times.
22059 if(decorations.idCount(dTALLGRASS)==0)
7595 {
7596
3/6
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 297 times.
✗ Branch 5 not taken.
297 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7597 297 }
7598 22059 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7599
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22059 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22059 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7600 sfx(thesfx,pan((int32_t)x));
7601 22059 }
7602 }
7603 1981754 }
7604
7605
2/2
✓ Branch 0 taken 3960376 times.
✓ Branch 1 taken 1972324 times.
5932700 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7606 {
7607
15/26
✓ Branch 0 taken 9418 times.
✓ Branch 1 taken 3950958 times.
✓ Branch 2 taken 9418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9418 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9226 times.
✓ Branch 9 taken 192 times.
✓ Branch 10 taken 9226 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 9226 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 9226 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 9226 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 9226 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 9226 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 9226 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 9226 times.
3960376 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7608 {
7609
2/2
✓ Branch 0 taken 9225 times.
✓ Branch 1 taken 1 times.
9237 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7610
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9215 times.
9226 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7611
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7612
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7613 {
7614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(decorations.idCount(dRIPPLES)==0)
7615 {
7616
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7617 1 }
7618 1 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (combobuf[watercheck].usrflags&cflag2)
7620 {
7621 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7622 {
7623 onpassivedmg = true;
7624 if (!damageovertimeclk)
7625 {
7626 int32_t curhp = game->get_life();
7627 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7628 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7629 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7630 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7631 {
7632 hclk = 48;
7633 hitdir = -1;
7634 action = gothit; FFCore.setHeroAction(gothit);
7635 }
7636 }
7637 if (combobuf[watercheck].attribytes[1] > 0)
7638 {
7639 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7640 else --damageovertimeclk;
7641 }
7642 else damageovertimeclk = 0;
7643 }
7644 else damageovertimeclk = 0;
7645 }
7646 1 else damageovertimeclk = 0;
7647 1 int32_t thesfx = combobuf[watercheck].attribytes[0];
7648
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7649 sfx(thesfx,pan((int32_t)x));
7650 1 }
7651 9226 }
7652 3960376 }
7653 else
7654 {
7655
7/8
✓ Branch 0 taken 2086 times.
✓ Branch 1 taken 1970238 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2009 times.
✓ Branch 6 taken 1970315 times.
✓ Branch 7 taken 2009 times.
1972324 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7656 {
7657
2/2
✓ Branch 0 taken 1996 times.
✓ Branch 1 taken 13 times.
2009 if(decorations.idCount(dRIPPLES)==0)
7658 {
7659
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7660 13 }
7661 2009 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2009 times.
2009 if (combobuf[watercheck].usrflags&cflag2)
7663 {
7664 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7665 {
7666 onpassivedmg = true;
7667 if (!damageovertimeclk)
7668 {
7669 int32_t curhp = game->get_life();
7670 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7671 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7672 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7673 }
7674 if (combobuf[watercheck].attribytes[1] > 0)
7675 {
7676 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7677 else --damageovertimeclk;
7678 }
7679 else damageovertimeclk = 0;
7680 }
7681 else damageovertimeclk = 0;
7682 }
7683 2009 else damageovertimeclk = 0;
7684 2009 int32_t thesfx = combobuf[watercheck].attribytes[0];
7685
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2009 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2009 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7686 sfx(thesfx,pan((int32_t)x));
7687 2009 }
7688 }
7689
7690
2/2
✓ Branch 0 taken 5932697 times.
✓ Branch 1 taken 3 times.
5932700 if(stomping)
7691 3 stomping = false;
7692
7693
2/2
✓ Branch 0 taken 5932396 times.
✓ Branch 1 taken 304 times.
5932700 if(getOnSideviewLadder())
7694 {
7695
4/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 304 times.
304 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7696 {
7697 setOnSideviewLadder(false);
7698 }
7699
2/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 304 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
304 else if(CANFORCEFACEUP)
7700 {
7701 setDir(up);
7702 }
7703 304 }
7704
7705
6/8
✓ Branch 0 taken 1980285 times.
✓ Branch 1 taken 3952415 times.
✓ Branch 2 taken 1980093 times.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 1980093 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1980093 times.
5932700 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7706 {
7707
2/2
✓ Branch 0 taken 1970747 times.
✓ Branch 1 taken 9346 times.
1980093 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7708 {
7709 9346 checkchest(cCHEST);
7710 9346 checkchest(cLOCKEDCHEST);
7711 9346 checkchest(cBOSSCHEST);
7712 9346 }
7713
2/2
✓ Branch 0 taken 1970747 times.
✓ Branch 1 taken 9346 times.
1980093 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7714 {
7715 9346 checkchest(cLOCKBLOCK);
7716 9346 checkchest(cBOSSLOCKBLOCK);
7717 9346 }
7718 1980093 }
7719 5932700 checksigns();
7720 5932700 checkgenpush();
7721
7722
2/2
✓ Branch 0 taken 3952885 times.
✓ Branch 1 taken 1979815 times.
5932700 if(isStanding())
7723 {
7724
1/2
✓ Branch 0 taken 1979815 times.
✗ Branch 1 not taken.
1979815 if(extra_jump_count > 0)
7725 extra_jump_count = 0;
7726 1979815 }
7727
1/2
✓ Branch 0 taken 5932700 times.
✗ Branch 1 not taken.
5932700 if(can_use_item(itype_hoverboots,i_hoverboots))
7728 {
7729 int32_t hoverid = current_item_id(itype_hoverboots);
7730 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7731 {
7732 if(hoverclk < 0) hoverclk = 0;
7733 hoverflags &= ~HOV_OUT;
7734 }
7735 }
7736 5932700 bool platformfell2 = false;
7737
2/2
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 5926617 times.
5932700 if(sideview_mode()) // Sideview gravity
7738 {
7739 //Handle falling through a platform
7740 6083 bool platformfell = false;
7741
4/4
✓ Branch 0 taken 3885 times.
✓ Branch 1 taken 2198 times.
✓ Branch 2 taken 3878 times.
✓ Branch 3 taken 7 times.
6083 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7742 {
7743
7/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 3 times.
7 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7744 7 y+=1; //Fall down a pixel instantly, through the platform.
7745
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(fall < 0) fall = 0;
7746
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(jumping < 0) jumping = 0;
7747 7 platformfell2 = true;
7748 7 }
7749 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6083 times.
6083 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7751 {
7752
14/22
✓ Branch 0 taken 5466 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 617 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 617 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 617 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 617 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 616 times.
✓ Branch 12 taken 616 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 616 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 616 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 616 times.
✓ Branch 20 taken 6082 times.
✓ Branch 21 taken 1 times.
6700 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7753
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
✓ Branch 2 taken 601 times.
✓ Branch 3 taken 15 times.
631 || ((y+(fall/100)<=0) &&
7754 // Extra checks if Smart Screen Scrolling is enabled
7755
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7756 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7757 {
7758 1 fall = jumping = 0; // Bumped his head
7759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7760 y -= y.getInt()%8; //fix coords
7761 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7763 {
7764 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7765 1 }
7766 1 }
7767 6083 }
7768 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7769
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6083 times.
✓ Branch 2 taken 6083 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6083 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6083 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6083 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6083 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 304 times.
✓ Branch 13 taken 5779 times.
6083 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7770 {
7771
1/2
✓ Branch 0 taken 5779 times.
✗ Branch 1 not taken.
5779 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7772 //zprint2("ydif is: %d\n", ydiff);
7773 //zprint2("ydif is: %d\n", (int32_t)fall);
7774 5779 falling_oldy = y; // Stomp Boots-related variable
7775
8/8
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 5025 times.
✓ Branch 2 taken 695 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 752 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 5777 times.
✓ Branch 7 taken 2 times.
5779 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7776 {
7777 2 ydiff -= (y.getInt()+ydiff)%16;
7778 2 }
7779
3/4
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 4603 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1176 times.
5779 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7780 {
7781
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 536 times.
1176 if(ydiff > 0)
7782 {
7783
2/2
✓ Branch 0 taken 622 times.
✓ Branch 1 taken 1366 times.
1988 for(auto q = 0; q < ydiff; ++q)
7784 {
7785
2/2
✓ Branch 0 taken 1348 times.
✓ Branch 1 taken 18 times.
1366 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7786 {
7787 18 ydiff = q;
7788 18 break;
7789 }
7790 1348 }
7791 640 }
7792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536 times.
536 else if(ydiff < 0)
7793 {
7794
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1048 times.
1584 for(auto q = 0; q > ydiff; --q)
7795 {
7796
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
2096 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7798 {
7799 ydiff = q;
7800 break;
7801 }
7802 1048 }
7803 536 }
7804 1176 }
7805 5779 y+=ydiff;
7806 5779 hs_starty+=ydiff;
7807
7808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5779 times.
5779 for(int32_t j=0; j<chainlinks.Count(); j++)
7809 {
7810 chainlinks.spr(j)->y+=ydiff;
7811 }
7812
7813
1/2
✓ Branch 0 taken 5779 times.
✗ Branch 1 not taken.
5779 if(Lwpns.idFirst(wHookshot)>-1)
7814 {
7815 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7816 }
7817
7818
1/2
✓ Branch 0 taken 5779 times.
✗ Branch 1 not taken.
5779 if(Lwpns.idFirst(wHSHandle)>-1)
7819 {
7820 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7821 }
7822 5779 }
7823
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
304 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7824 {
7825 fall = hoverclk = jumping = 0;
7826 inair = false;
7827 hoverflags = 0;
7828 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7829 {
7830 WalkflagInfo info;
7831 if (game->get_watergrav()<0)
7832 {
7833 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7834 execute(info);
7835 }
7836 else
7837 {
7838 info = walkflag(x,y+15+2,2,down);
7839 execute(info);
7840 }
7841 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7842 }
7843 }
7844 // Stop hovering/falling if you land on something.
7845 6083 bool needFall = false;
7846
7/8
✓ Branch 0 taken 2207 times.
✓ Branch 1 taken 3876 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6083 times.
✓ Branch 4 taken 4154 times.
✓ Branch 5 taken 1929 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4153 times.
6083 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7847 {
7848 4153 stop_item_sfx(itype_hoverboots);
7849
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4153 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4153 times.
4153 && !getOnSideviewLadder()
7851 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7852 y-=(int32_t)y%8; //fix position
7853 4153 fall = hoverclk = jumping = 0;
7854 4153 inair = false;
7855 4153 hoverflags = 0;
7856
7857
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4153 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4153 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7858 y = 160;
7859 4153 }
7860 // Stop hovering if you press down.
7861
3/6
✓ Branch 0 taken 1930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1930 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1930 times.
✗ Branch 5 not taken.
1930 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7862 {
7863 stop_item_sfx(itype_hoverboots);
7864 hoverclk = -hoverclk;
7865 reset_ladder();
7866 fall = (zinit.gravity2 / 100);
7867 inair = false;
7868 }
7869
7/8
✓ Branch 0 taken 1930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 1314 times.
✓ Branch 4 taken 584 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 581 times.
1930 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell)
7870 {
7871 581 zfix my = y + (zinit.gravity2/100);
7872 581 needFall = true;
7873
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1258 times.
1271 for (zfix ty = y+1; ty < my; ++ty)
7874 {
7875 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
7876
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 568 times.
1258 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
7877 {
7878 568 y = ty;
7879
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 557 times.
568 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
7880 {
7881
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 5 times.
557 if(!slopeid)
7882 5 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
7883 557 onplatid = 5;
7884 557 }
7885 568 needFall = false;
7886 568 break;
7887 }
7888 690 }
7889 581 }
7890 1349 else needFall = true;
7891 // Continue falling.
7892
7893
4/4
✓ Branch 0 taken 5917 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 4721 times.
✓ Branch 3 taken 1196 times.
6083 if(fall <= (int32_t)zinit.terminalv && needFall)
7894 {
7895 1196 inair = true;
7896
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1158 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
1196 if(fall != 0 || hoverclk>0)
7897 1158 jumping++;
7898
7899 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
7900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
1196 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7901 {
7902 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
7903 || (y<=(bigHitbox?9:1) &&
7904 // Extra checks if Smart Screen Scrolling is enabled
7905 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7906 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
7907 && fall < 0)
7908 {
7909 fall = jumping = 0; // Bumped his head
7910
7911 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7912 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7913 {
7914 checkdamagecombos(x+4, x+12, y-1, y-1);
7915 }
7916 }
7917 }
7918 else
7919 {
7920
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1196 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1196 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1196 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1196 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1196 times.
✓ Branch 14 taken 1196 times.
✗ Branch 15 not taken.
2392 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
7921
3/4
✓ Branch 0 taken 1196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1165 times.
1196 || ((y<=0) &&
7922 // Extra checks if Smart Screen Scrolling is enabled
7923
2/6
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7924 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
7925 && fall < 0)
7926 {
7927 fall = jumping = 0; // Bumped his head
7928 y -= y.getInt()%8; //fix coords
7929 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7930 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7931 {
7932 checkdamagecombos(x+4, x+12, y-1, y-1);
7933 }
7934 }
7935 }
7936
7937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
1196 if(hoverclk > 0)
7938 {
7939 if(hoverclk > 0 && !(hoverflags&HOV_INF))
7940 {
7941 --hoverclk;
7942 }
7943
7944 if(!hoverclk && !ladderx && !laddery)
7945 {
7946 fall += (zinit.gravity2 / 100);
7947 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
7948 }
7949 }
7950
5/12
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 551 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1196 else if(fall+int32_t((zinit.gravity2 / 100)) > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
7951 {
7952 int32_t itemid = current_item_id(itype_hoverboots);
7953 if(hoverclk < 0)
7954 hoverclk = -hoverclk;
7955 else
7956 {
7957 fall = jumping = 0;
7958 if(itemsbuf[itemid].misc1)
7959 hoverclk = itemsbuf[itemid].misc1;
7960 else
7961 {
7962 hoverclk = 1;
7963 hoverflags |= HOV_INF;
7964 }
7965
7966
7967 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
7968 }
7969 if(itemsbuf[itemid].wpn)
7970 decorations.add(new dHover(x, y, dHOVER, 0));
7971 }
7972
4/8
✓ Branch 0 taken 1196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1196 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1196 times.
1196 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
7973 {
7974 1196 fall += (zinit.gravity2 / 100);
7975
7976 1196 }
7977 1196 }
7978 6083 }
7979 else // Topdown gravity
7980 {
7981
3/4
✓ Branch 0 taken 3950838 times.
✓ Branch 1 taken 1975779 times.
✓ Branch 2 taken 1975779 times.
✗ Branch 3 not taken.
5926617 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
7982
3/4
✓ Branch 0 taken 3950838 times.
✓ Branch 1 taken 1975779 times.
✓ Branch 2 taken 1975779 times.
✗ Branch 3 not taken.
5926617 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
7983
4/4
✓ Branch 0 taken 1975659 times.
✓ Branch 1 taken 3950958 times.
✓ Branch 2 taken 3951078 times.
✓ Branch 3 taken 5926737 times.
5926617 if(z>0||fakez>0)
7984 {
7985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7902036 switch(action)
7986 {
7987 case swimming:
7988 {
7989 diveclk=0;
7990 action=walking; FFCore.setHeroAction(walking);
7991
7992 break;
7993 }
7994 case waterhold1:
7995 {
7996 action=landhold1; FFCore.setHeroAction(landhold1);
7997 break;
7998 }
7999
8000 case waterhold2:
8001 {
8002 action=landhold2; FFCore.setHeroAction(landhold2);
8003 break;
8004 }
8005
8006 default:
8007 120 break;
8008 }
8009 120 }
8010
8011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5926857 times.
5926857 for(int32_t j=0; j<chainlinks.Count(); j++)
8012 {
8013 chainlinks.spr(j)->z=z;
8014 chainlinks.spr(j)->fakez=fakez;
8015 }
8016
8017
1/2
✓ Branch 0 taken 5926857 times.
✗ Branch 1 not taken.
5926857 if(Lwpns.idFirst(wHookshot)>-1)
8018 {
8019 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8020 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8021 }
8022
8023
1/2
✓ Branch 0 taken 5926857 times.
✗ Branch 1 not taken.
5926857 if(Lwpns.idFirst(wHSHandle)>-1)
8024 {
8025 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8026 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8027 }
8028
8029
3/4
✓ Branch 0 taken 1975659 times.
✓ Branch 1 taken 3951198 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1975659 times.
5926857 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8030 {
8031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1975659 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1975659 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8032 {
8033
2/2
✓ Branch 0 taken 1975656 times.
✓ Branch 1 taken 3 times.
1975659 if(fall > 0)
8034 {
8035
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 1 times.
3 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8036 1 sfx(WAV_ZN1SPLASH,x.getInt());
8037
8038 3 stomping = true;
8039 3 }
8040 1975659 }
8041 1975659 z = fall = 0;
8042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1975659 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1975659 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8043 {
8044 1975659 jumping = 0;
8045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975659 times.
1975659 if(check_pitslide(true) == -1)
8046 {
8047 1975659 hoverclk = 0;
8048 1975659 hoverflags = 0;
8049 1975659 }
8050 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8051 {
8052 if(!--hoverclk)
8053 {
8054 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8055 }
8056 }
8057 1975659 }
8058 1975659 }
8059
3/4
✓ Branch 0 taken 1975779 times.
✓ Branch 1 taken 3951078 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1975779 times.
5926857 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8060 {
8061
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1975659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
1975779 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8062 {
8063
1/2
✓ Branch 0 taken 1975659 times.
✗ Branch 1 not taken.
1975659 if(fakefall > 0)
8064 {
8065 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8066 sfx(WAV_ZN1SPLASH,x.getInt());
8067
8068 stomping = true;
8069 }
8070 1975659 }
8071 1975779 fakez = fakefall = 0;
8072
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1975659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
1975779 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8073 {
8074 1975659 jumping = 0;
8075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975659 times.
1975659 if(check_pitslide(true) == -1)
8076 {
8077 1975659 hoverclk = 0;
8078 1975659 hoverflags = 0;
8079 1975659 }
8080 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8081 {
8082 if(!--hoverclk)
8083 {
8084 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8085 }
8086 }
8087 1975659 }
8088 1975779 }
8089
8/10
✓ Branch 0 taken 1975779 times.
✓ Branch 1 taken 3951078 times.
✓ Branch 2 taken 1975779 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1975539 times.
✓ Branch 5 taken 240 times.
✓ Branch 6 taken 1975659 times.
✓ Branch 7 taken 1975659 times.
✓ Branch 8 taken 1975659 times.
✗ Branch 9 not taken.
5926857 if(fall <= (int32_t)zinit.terminalv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= (int32_t)zinit.terminalv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8090 {
8091
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3951198 if(fall != 0 || fakefall != 0 || hoverclk>0)
8092 117 jumping++;
8093
8094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(hoverclk > 0)
8095 {
8096 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8097 {
8098 --hoverclk;
8099 }
8100
8101 if(!hoverclk)
8102 {
8103 if (fall <= (int32_t)zinit.terminalv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += (zinit.gravity2 / 100);
8104 if (fakefall <= (int32_t)zinit.terminalv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += (zinit.gravity2 / 100);
8105 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8106 }
8107 }
8108
9/16
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 117 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 120 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
120 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+(int32_t)(zinit.gravity2 / 100) > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8109 {
8110 if(hoverclk < 0)
8111 hoverclk = -hoverclk;
8112 else
8113 {
8114 fall = 0;
8115 fakefall = 0;
8116 int32_t itemid = current_item_id(itype_hoverboots);
8117 if(itemsbuf[itemid].misc1)
8118 hoverclk = itemsbuf[itemid].misc1;
8119 else
8120 {
8121 hoverclk = 1;
8122 hoverflags |= HOV_INF;
8123 }
8124 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8125 }
8126 decorations.add(new dHover(x, y, dHOVER, 0));
8127 }
8128 else
8129 {
8130
3/6
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 120 times.
120 if (fall <= (int32_t)zinit.terminalv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += (zinit.gravity2 / 100);
8131
3/6
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
120 if (fakefall <= (int32_t)zinit.terminalv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += (zinit.gravity2 / 100);
8132 }
8133 120 }
8134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975779 times.
1975779 if (fakez<0) fakez = 0;
8135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975779 times.
1975779 if (z<0) z = 0;
8136 }
8137
8138
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 if(drunkclk)
8139 {
8140 --drunkclk;
8141 }
8142
8143
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 if(lstunclock > 0)
8144 {
8145 // also cancel Hero's attack
8146 attackclk = 0;
8147
8148 if( FFCore.getHeroAction() != stunned )
8149 {
8150 tempaction=action; //update so future checks won't do this
8151 //action=freeze; //setting this makes the player invincible while stunned -V
8152 FFCore.setHeroAction(stunned);
8153 }
8154 --lstunclock;
8155 }
8156 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8157 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981862 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981862 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8159 {
8160 action=tempaction; FFCore.setHeroAction(tempaction);
8161 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8162 //action=none; FFCore.setHeroAction(none);
8163 }
8164
8165
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 if( lbunnyclock > 0 )
8166 {
8167 --lbunnyclock;
8168 }
8169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981862 times.
1981862 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8170 {
8171 int32_t itemid = current_item_id(itype_pearl);
8172 if(itemid > -1)
8173 {
8174 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8175 lbunnyclock = 0;
8176 }
8177 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8178 {
8179 lbunnyclock = -1;
8180 }
8181 }
8182
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 else if(lbunnyclock == -1) //dmap-caused bunny effect
8183 {
8184 lbunnyclock = 0;
8185 }
8186
8187
9/16
✓ Branch 0 taken 1981674 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 1972136 times.
✓ Branch 3 taken 9538 times.
✓ Branch 4 taken 1972136 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1972136 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1972136 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18026 times.
✓ Branch 15 taken 1954110 times.
1981862 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8188
1/2
✓ Branch 0 taken 1972136 times.
✗ Branch 1 not taken.
1972136 && action != gothit)
8189 {
8190
2/3
✓ Branch 0 taken 864773 times.
✓ Branch 1 taken 1089337 times.
✗ Branch 2 not taken.
1954110 switch(dir)
8191 {
8192 case up:
8193 case down:
8194 864773 x=(x.getInt()+4)&0xFFF8;
8195 864773 break;
8196
8197 case left:
8198 case right:
8199 1089337 y=(y.getInt()+4)&0xFFF8;
8200 1089337 break;
8201 }
8202 1954110 }
8203
8204
4/4
✓ Branch 0 taken 53078 times.
✓ Branch 1 taken 1928784 times.
✓ Branch 2 taken 43764 times.
✓ Branch 3 taken 9314 times.
1981862 if((watch==true) && clockclk)
8205 {
8206 9314 --clockclk;
8207
8208
2/2
✓ Branch 0 taken 9289 times.
✓ Branch 1 taken 25 times.
9314 if(!clockclk)
8209 {
8210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(cheat_superman==false)
8211 {
8212 25 setClock(false);
8213 25 }
8214
8215 25 watch=false;
8216
8217
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<eMAXGUYS; i++)
8218 {
8219
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12800 times.
12801 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8220 {
8221 1 addenemy(0,0,i,0);
8222 1 }
8223 12800 }
8224 25 }
8225 9314 }
8226
8227
2/4
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1981862 times.
1981862 if(hookshot_frozen || switch_hooked)
8228 {
8229 if(hookshot_used || switch_hooked)
8230 {
8231 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8232 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8233
8234 if(pull_hero || switch_hooked)
8235 {
8236 if(hs_switcher || switch_hooked)
8237 {
8238 hs_fix = false;
8239 if(switchhookclk)
8240 {
8241 --switchhookclk;
8242 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8243 {
8244 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8245 reset_hookshot();
8246 else
8247 {
8248 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8249 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8250
8251 if(hooked_combopos > -1) //Switching combos
8252 {
8253 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8254 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8255 {
8256 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8257 for(int q = max_layer; q > -1; --q)
8258 {
8259 if(!(hooked_layerbits & (1<<q)))
8260 continue; //non-switching layer
8261 mapscr* scr = FFCore.tempScreens[q];
8262 newcombo const& cmb = combobuf[scr->data[targpos]];
8263 int32_t srcfl = scr->sflag[targpos];
8264 newcombo const& comb2 = combobuf[scr->data[plpos]];
8265 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8266 //{Check push status
8267 bool isFakePush = false;
8268 if(cmb.type == cSWITCHHOOK)
8269 {
8270 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8271 isFakePush = true;
8272 }
8273 bool isPush = isFakePush;
8274 if(!isPush) switch(srcfl)
8275 {
8276 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8277 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8278 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8279 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8280 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8281 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8282 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8283 isPush = true;
8284 }
8285 if(!isPush) switch(cmb.flag)
8286 {
8287 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8288 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8289 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8290 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8291 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8292 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8293 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8294 isPush = true;
8295 }
8296 if(srcfl==mfPUSHED) isPush = false;
8297 //}
8298 if(cmb.type == cSWITCHHOOK) //custom flags and such
8299 {
8300 if(cmb.usrflags&cflag3) //Breaks on swap
8301 {
8302 int32_t it = -1;
8303 int32_t thedropset = -1;
8304 if(cmb.usrflags&cflag4) //drop item
8305 {
8306 if(cmb.usrflags&cflag5)
8307 it = cmb.attribytes[2];
8308 else
8309 {
8310 it = select_dropitem(cmb.attribytes[2]);
8311 thedropset = cmb.attribytes[2];
8312 }
8313 }
8314
8315 breakable* br = new breakable(x, y, zfix(0),
8316 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8317 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8318 br->switch_hooked = true;
8319 decorations.add(br);
8320 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8321 hooked_undercombos[q] = -1;
8322
8323 if(cmb.usrflags&cflag6)
8324 {
8325 scr->data[targpos]++;
8326 }
8327 else
8328 {
8329 scr->data[targpos] = scr->undercombo;
8330 scr->cset[targpos] = scr->undercset;
8331 if(cmb.usrflags&cflag2)
8332 scr->sflag[targpos] = 0;
8333 }
8334 }
8335 else if(isPush)
8336 {
8337 //Simulate a block clicking into place
8338 movingblock mtemp;
8339 mtemp.clear();
8340 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8341 mtemp.dir = getPushDir(scr->sflag[targpos]);
8342 if(mtemp.dir < 0)
8343 mtemp.dir = getPushDir(cmb.flag);
8344 mtemp.clk = 1;
8345 if(isFakePush)
8346 mtemp.force_many = true;
8347 mtemp.animate(0);
8348 if((mtemp.bhole || mtemp.trigger)
8349 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8350 || comb2.flag == mfBLOCKTRIGGER
8351 || comb2.flag == mfBLOCKHOLE))
8352 {
8353 scr->data[targpos] = scr->undercombo;
8354 scr->cset[targpos] = scr->undercset;
8355 scr->sflag[targpos] = 0;
8356 }
8357 else
8358 {
8359 scr->data[targpos] = c;
8360 scr->cset[targpos] = cs;
8361 if(cmb.usrflags&cflag2)
8362 scr->sflag[targpos] = fl;
8363 else
8364 scr->sflag[targpos] = 0;
8365 }
8366 }
8367 else
8368 {
8369 scr->data[plpos] = scr->data[targpos];
8370 scr->cset[plpos] = scr->cset[targpos];
8371 if(cmb.usrflags&cflag2)
8372 scr->sflag[plpos] = scr->sflag[targpos];
8373 scr->data[targpos] = c;
8374 scr->cset[targpos] = cs;
8375 if(cmb.usrflags&cflag2)
8376 scr->sflag[targpos] = fl;
8377 }
8378 }
8379 else if(isCuttableType(cmb.type)) //Break and drop effects
8380 {
8381 int32_t breakcs = scr->cset[targpos];
8382 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8383 {
8384 scr->data[targpos]++;
8385 }
8386 else
8387 {
8388 scr->data[targpos] = scr->undercombo;
8389 scr->cset[targpos] = scr->undercset;
8390 scr->sflag[targpos] = 0;
8391 }
8392
8393 int32_t it = -1;
8394 int32_t thedropset = -1;
8395 if(isCuttableItemType(cmb.type)) //Drop an item
8396 {
8397 if ( (cmb.usrflags&cflag2) )
8398 {
8399 if(cmb.usrflags&cflag11)
8400 it = cmb.attribytes[1];
8401 else
8402 {
8403 it = select_dropitem(cmb.attribytes[1]);
8404 thedropset = cmb.attribytes[1];
8405 }
8406 }
8407 else
8408 {
8409 it = select_dropitem(12);
8410 thedropset = 12;
8411 }
8412 }
8413
8414 byte breaksfx = 0;
8415 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8416 {
8417 if (cmb.usrflags&cflag3)
8418 {
8419 breaksfx = cmb.attribytes[2];
8420 }
8421 else if(isBushType(cmb.type)
8422 || isFlowersType(cmb.type)
8423 || isGrassType(cmb.type))
8424 {
8425 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8426 }
8427 }
8428
8429 //Clipping sprite
8430 int16_t decotype = (cmb.usrflags & cflag1) ?
8431 ((cmb.usrflags & cflag10)
8432 ? (cmb.attribytes[0])
8433 : (-1))
8434 : (0);
8435 if(decotype > 3) decotype = 0;
8436 if(!decotype)
8437 decotype = (isBushType(cmb.type) ? 1
8438 : (isFlowersType(cmb.type) ? 2
8439 : (isGrassType(cmb.type) ? 3
8440 : ((cmb.usrflags & cflag1) ? -1
8441 : -2))));
8442
8443 breakable* br = new breakable(x, y, zfix(0),
8444 cmb, breakcs, it, thedropset, breaksfx,
8445 decotype, cmb.attribytes[0], switchhookclk);
8446 br->switch_hooked = true;
8447 decorations.add(br);
8448 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8449 hooked_undercombos[q] = -1;
8450 }
8451 else //Unknown type, just swap combos.
8452 {
8453 if(isPush)
8454 {
8455 //Simulate a block clicking into place
8456 movingblock mtemp;
8457 mtemp.clear();
8458 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8459 mtemp.dir = getPushDir(scr->sflag[targpos]);
8460 if(mtemp.dir < 0)
8461 mtemp.dir = getPushDir(cmb.flag);
8462 mtemp.clk = 1;
8463 mtemp.animate(0);
8464 if(mtemp.bhole || mtemp.trigger)
8465 {
8466 scr->data[targpos] = scr->undercombo;
8467 scr->cset[targpos] = scr->undercset;
8468 scr->sflag[targpos] = 0;
8469 }
8470 else
8471 {
8472 scr->data[targpos] = c;
8473 scr->cset[targpos] = cs;
8474 scr->sflag[targpos] = 0;
8475 }
8476 }
8477 else
8478 {
8479 scr->data[plpos] = scr->data[targpos];
8480 scr->cset[plpos] = scr->cset[targpos];
8481 scr->data[targpos] = c;
8482 scr->cset[targpos] = cs;
8483 }
8484 }
8485 }
8486 if(switchhook_cost_item > -1)
8487 paymagiccost(switchhook_cost_item);
8488 zfix tx = x, ty = y;
8489 //Position the player at the combo
8490 x = COMBOX(targpos);
8491 y = COMBOY(targpos);
8492 dir = oppositeDir[dir];
8493 if(w && hw)
8494 {
8495 //Calculate chain shift
8496 zfix dx = (x-tx);
8497 zfix dy = (y-ty);
8498 if(w->dir < 4)
8499 {
8500 if(w->dir & 2)
8501 dx = 0;
8502 else dy = 0;
8503 }
8504 //Position the hook head at the handle
8505 w->x = hw->x + dx;
8506 w->y = hw->y + dy;
8507 w->dir = oppositeDir[w->dir];
8508 w->doAutoRotate(true);
8509 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8510 w->flip ^= hflip;
8511 //Position the handle appropriately
8512 hw->x = x-(hw->x-tx);
8513 hw->y = y-(hw->y-ty);
8514 hw->dir = oppositeDir[hw->dir];
8515 hw->doAutoRotate(true);
8516 hw->flip ^= hflip;
8517 //Move chains
8518 for(int32_t j=0; j<chainlinks.Count(); j++)
8519 {
8520 chainlinks.spr(j)->x += dx;
8521 chainlinks.spr(j)->y += dy;
8522 }
8523 }
8524 hooked_combopos = plpos; //flip positions
8525 }
8526 else reset_hookshot();
8527 }
8528 else if(switching_object) //Switching an object
8529 {
8530 if(switchhook_cost_item > -1)
8531 paymagiccost(switchhook_cost_item);
8532 zfix tx = x, ty = y;
8533 //Position the player at the object
8534 x = switching_object->x;
8535 y = switching_object->y;
8536 dir = oppositeDir[dir];
8537 //Position the object at the player
8538 switching_object->x = tx;
8539 switching_object->y = ty;
8540 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8541 switching_object->dir = oppositeDir[switching_object->dir];
8542 solid_update(false);
8543 switching_object->solid_update(false);
8544 if(item* it = dynamic_cast<item*>(switching_object))
8545 {
8546 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8547 {
8548 movefairynew2(it->x, it->y, *it);
8549 }
8550 }
8551 if(w && hw) //!TODO No fucking clue if diagonals work
8552 {
8553 //Calculate chain shift
8554 zfix dx = (x-tx);
8555 zfix dy = (y-ty);
8556 if(w->dir < 4)
8557 {
8558 if(w->dir & 2)
8559 dx = 0;
8560 else dy = 0;
8561 }
8562 //Position the hook head at the handle
8563 w->x = hw->x + dx;
8564 w->y = hw->y + dy;
8565 w->dir = oppositeDir[w->dir];
8566 w->doAutoRotate(true);
8567 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8568 w->flip ^= hflip;
8569 w->solid_update(false);
8570 //Position the handle appropriately
8571 hw->x = x-(hw->x-tx);
8572 hw->y = y-(hw->y-ty);
8573 hw->dir = oppositeDir[hw->dir];
8574 hw->doAutoRotate(true);
8575 hw->flip ^= hflip;
8576 hw->solid_update(false);
8577 //Move chains
8578 for(int32_t j=0; j<chainlinks.Count(); j++)
8579 {
8580 chainlinks.spr(j)->x += dx;
8581 chainlinks.spr(j)->y += dy;
8582 }
8583 }
8584 }
8585 }
8586 }
8587 else if(!switchhookclk)
8588 {
8589 reset_hookshot();
8590 }
8591 }
8592 else reset_hookshot();
8593 }
8594 else
8595 {
8596 sprite *t;
8597 int32_t i;
8598
8599 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8600 {
8601 /* do nothing */
8602 }
8603
8604 t = Lwpns.spr(i);
8605
8606 for(i=0; i<Lwpns.Count(); i++)
8607 {
8608 sprite *s = Lwpns.spr(i);
8609
8610 if(s->id==wHookshot)
8611 {
8612 if (abs((s->y) - y) >= 1)
8613 {
8614 if((s->y)>y)
8615 {
8616 y+=4;
8617
8618 if(Lwpns.idFirst(wHSHandle)!=-1)
8619 {
8620 t->y+=4;
8621 }
8622
8623 hs_starty+=4;
8624 }
8625
8626 if((s->y)<y)
8627 {
8628 y-=4;
8629
8630 if(Lwpns.idFirst(wHSHandle)!=-1)
8631 {
8632 t->y-=4;
8633 }
8634
8635 hs_starty-=4;
8636 }
8637 }
8638 else
8639 {
8640 y = (s->y);
8641 }
8642 if (abs((s->x) - x) >= 1)
8643 {
8644 if((s->x)>x)
8645 {
8646 x+=4;
8647
8648 if(Lwpns.idFirst(wHSHandle)!=-1)
8649 {
8650 t->x+=4;
8651 }
8652
8653 hs_startx+=4;
8654 }
8655
8656 if((s->x)<x)
8657 {
8658 x-=4;
8659
8660 if(Lwpns.idFirst(wHSHandle)!=-1)
8661 {
8662 t->x-=4;
8663 }
8664
8665 hs_startx-=4;
8666 }
8667 }
8668 else
8669 {
8670 x = (s->x);
8671 }
8672 }
8673 }
8674 }
8675 }
8676 }
8677 else
8678 {
8679 Lwpns.del(Lwpns.idFirst(wHSHandle));
8680 reset_hookshot();
8681 }
8682
8683 if(hs_fix)
8684 {
8685 if(dir==up)
8686 {
8687 y=int32_t(y+7)&0xF0;
8688 }
8689
8690 if(dir==down)
8691 {
8692 y=int32_t(y+7)&0xF0;
8693 }
8694
8695 if(dir==left)
8696 {
8697 x=int32_t(x+7)&0xF0;
8698 }
8699
8700 if(dir==right)
8701 {
8702 x=int32_t(x+7)&0xF0;
8703 }
8704
8705 hs_fix=false;
8706 }
8707
8708 }
8709
8710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981862 times.
1981862 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8711 {
8712
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1981145 times.
1981862 if(DrunkrLbtn())
8713 717 selectNextBWpn(SEL_LEFT);
8714
2/2
✓ Branch 0 taken 1980250 times.
✓ Branch 1 taken 895 times.
1981145 else if(DrunkrRbtn())
8715 895 selectNextBWpn(SEL_RIGHT);
8716 1981862 }
8717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981862 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981862 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8718 {
8719 if (rEx3btn())
8720 selectNextAWpn(SEL_LEFT);
8721 else if (rEx4btn())
8722 selectNextAWpn(SEL_RIGHT);
8723 }
8724
8725
2/2
✓ Branch 0 taken 1981861 times.
✓ Branch 1 taken 1 times.
1981862 if(rPbtn())
8726 {
8727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8728 1 onViewMap();
8729 1 }
8730
2/2
✓ Branch 0 taken 955199 times.
✓ Branch 1 taken 1981862 times.
2937061 for(int32_t i=0; i<Lwpns.Count(); i++)
8731 {
8732 955199 weapon *w = ((weapon*)Lwpns.spr(i));
8733
8734
5/6
✓ Branch 0 taken 951584 times.
✓ Branch 1 taken 3615 times.
✓ Branch 2 taken 832048 times.
✓ Branch 3 taken 119536 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 832048 times.
955199 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8735 123151 addsparkle(i);
8736 955199 }
8737
8738
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 if(Lwpns.idCount(wPhantom))
8739 {
8740 addsparkle2(pDINSFIREROCKET,pDINSFIREROCKETTRAIL);
8741 addsparkle2(pDINSFIREROCKETRETURN,pDINSFIREROCKETTRAILRETURN);
8742 addsparkle2(pNAYRUSLOVEROCKET1,pNAYRUSLOVEROCKETTRAIL1);
8743 addsparkle2(pNAYRUSLOVEROCKET2,pNAYRUSLOVEROCKETTRAIL2);
8744 addsparkle2(pNAYRUSLOVEROCKETRETURN1,pNAYRUSLOVEROCKETTRAILRETURN1);
8745 addsparkle2(pNAYRUSLOVEROCKETRETURN2,pNAYRUSLOVEROCKETTRAILRETURN2);
8746 }
8747
8748 // Pay magic cost for Byrna beams
8749
8750 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8751
1/2
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
1981862 if(Lwpns.idCount(wCByrna))
8752 {
8753 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8754 int32_t itemid = ew->parentitem;
8755
8756 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8757 {
8758 for(int32_t i=0; i<Lwpns.Count(); i++)
8759 {
8760 weapon *w = ((weapon*)Lwpns.spr(i));
8761
8762 if(w->id==wCByrna)
8763 {
8764 w->dead=1;
8765 }
8766
8767 }
8768 //kill the sound effect for the orbits -Z 14FEB2019
8769 stop_sfx(itemsbuf[itemid].usesound);
8770 }
8771 else paymagiccost(itemid);
8772 }
8773
8774
3/4
✓ Branch 0 taken 1981742 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 1981742 times.
✗ Branch 3 not taken.
1981862 if(z==0&&fakez==0)
8775 {
8776 1981742 switchblock_z = 0;
8777
1/2
✓ Branch 0 taken 1981742 times.
✗ Branch 1 not taken.
1981742 if(switchblock_offset)
8778 {
8779 switchblock_offset=false;
8780 yofs += 8;
8781 }
8782 1981742 }
8783
2/2
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 1975779 times.
1981862 if(!isSideViewHero())
8784 {
8785 1975779 int32_t tx = x.getInt()+8,
8786 1975779 ty = y.getInt()+8;//(bigHitbox?8:12);
8787
4/4
✓ Branch 0 taken 1975673 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 1975584 times.
1975779 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8788 {
8789
2/2
✓ Branch 0 taken 1975584 times.
✓ Branch 1 taken 5926752 times.
7902336 for(int32_t q = 0; q < 3; ++q)
8790 {
8791
4/4
✓ Branch 0 taken 3951168 times.
✓ Branch 1 taken 1975584 times.
✓ Branch 2 taken 335884 times.
✓ Branch 3 taken 3615284 times.
5926752 if(q && !tmpscr2[q-1].valid) continue;
8792 2311468 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2311468 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2311468 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8794 int32_t b = 1;
8795 if(tx&8) b <<= 2;
8796 if(ty&8) b <<= 1;
8797 b |= (b<<4); //check equivalent effect flag too
8798 if((cmb.walk&b)==b) //solid and effecting
8799 {
8800 if(z==0&&fakez==0)
8801 {
8802 if(cmb.usrflags&cflag10)
8803 {
8804 if(!switchblock_offset)
8805 {
8806 switchblock_offset=true;
8807 yofs -= 8;
8808 }
8809 }
8810 else
8811 {
8812 if(switchblock_offset)
8813 {
8814 switchblock_offset=false;
8815 yofs += 8;
8816 }
8817 }
8818 }
8819 if(cmb.attributes[2]>0 && switchblock_z>=0)
8820 {
8821 if(z==0&&fakez==0)
8822 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8823 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8824 {
8825 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8826 }
8827 }
8828 else switchblock_z = -1;
8829 break;
8830 }
8831 }
8832 1975584 }
8833 1975779 }
8834 1981862 ClearhitHeroUIDs(); //clear them before we advance.
8835 1981862 checkhit();
8836
8837 1981862 bool forcedeath = dying_flags&DYING_FORCED;
8838 1981862 bool norev = (dying_flags&DYING_NOREV);
8839
4/6
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1981848 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
1981862 if(forcedeath || (game->get_life()<=0 && !immortal))
8840 {
8841
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(forcedeath)
8842 game->set_life(0);
8843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!norev)
8844
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3584 times.
3598 for(size_t slot = 0; slot < 256; ++slot)
8845 {
8846
1/2
✓ Branch 0 taken 3584 times.
✗ Branch 1 not taken.
3584 if(size_t bind = game->get_bottle_slot(slot))
8847 {
8848 bottletype const* bt = &QMisc.bottle_types[bind-1];
8849 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8850 continue;
8851 word toFill[3] = { 0 };
8852 for(size_t q = 0; q < 3; ++q)
8853 {
8854 char c = bt->counter[q];
8855 if(c > -1)
8856 {
8857 if(bt->flags & (1<<q))
8858 {
8859 toFill[q] = (bt->amount[q]==100)
8860 ? game->get_maxcounter(c)
8861 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8862 }
8863 else toFill[q] = bt->amount[q];
8864 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8865 {
8866 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8867 }
8868 }
8869 }
8870 if(bt->flags & BTFLAG_CURESWJINX)
8871 {
8872 swordclk = 0;
8873 verifyAWpn();
8874 }
8875 if(bt->flags & BTFLAG_CUREITJINX)
8876 itemclk = 0;
8877 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
8878 {
8879 int32_t itemid = find_bottle_for_slot(slot,true);
8880 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
8881 if(itemid > -1)
8882 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8883 for(size_t q = 0; q < 20; ++q)
8884 do_death_refill_waitframe();
8885 double inc = max/60.0; //1 second
8886 double xtra[3]{ 0 };
8887 for(size_t q = 0; q < 60; ++q)
8888 {
8889 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
8890 sfx(QMisc.miscsfx[sfxREFILL]);
8891 for(size_t j = 0; j < 3; ++j)
8892 {
8893 xtra[j] += inc;
8894 word f = floor(xtra[j]);
8895 xtra[j] -= f;
8896 if(toFill[j] > f)
8897 {
8898 toFill[j] -= f;
8899 game->change_counter(f,bt->counter[j]);
8900 }
8901 else if(toFill[j])
8902 {
8903 game->change_counter(toFill[j],bt->counter[j]);
8904 toFill[j] = 0;
8905 }
8906 }
8907 do_death_refill_waitframe();
8908 }
8909 for(size_t j = 0; j < 3; ++j)
8910 {
8911 if(toFill[j])
8912 {
8913 game->change_counter(toFill[j],bt->counter[j]);
8914 toFill[j] = 0;
8915 }
8916 }
8917 for(size_t q = 0; q < 20; ++q)
8918 do_death_refill_waitframe();
8919 }
8920 game->set_bottle_slot(slot,bt->next_type);
8921 if(game->get_life() > 0)
8922 {
8923 dying_flags = 0;
8924 forcedeath = false;
8925 break; //Revived! Stop drinking things...
8926 }
8927 }
8928 3598 }
8929
8930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
8931 {
8932 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
8933 {
8934 // So scripts can have one frame to handle hp zero events
8935 if(norev || false == (last_hurrah = !last_hurrah))
8936 {
8937 dying_flags = 0;
8938 drunkclk=0;
8939 lstunclock = 0;
8940 is_conveyor_stunned = 0;
8941 FFCore.setHeroAction(dying);
8942 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
8943 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
8944 ALLOFF(true,true);
8945 GameFlags |= GAMEFLAG_NO_F6;
8946 if(!debug_enabled)
8947 {
8948 Paused=false;
8949 }
8950 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
8951 {
8952 FFCore.runOnDeathEngine();
8953 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
8954 }
8955 Playing = false;
8956 heroDeathAnimation();
8957 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
8958 {
8959 Playing = true;
8960 FFCore.runOnDeathEngine();
8961 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
8962 Playing = false;
8963 }
8964 GameFlags &= ~GAMEFLAG_NO_F6;
8965 ALLOFF(true,true);
8966 return true;
8967 }
8968 }
8969 }
8970 else //2.50.x
8971 {
8972 // So scripts can have one frame to handle hp zero events
8973
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 if(false == (last_hurrah = !last_hurrah))
8974 {
8975 7 drunkclk=0;
8976 7 heroDeathAnimation();
8977
8978 7 return true;
8979 }
8980 }
8981 7 }
8982 1981848 else last_hurrah=false;
8983
8984
2/2
✓ Branch 0 taken 14507 times.
✓ Branch 1 taken 1967348 times.
1981855 if(swordclk>0)
8985 {
8986 14507 --swordclk;
8987
2/2
✓ Branch 0 taken 14433 times.
✓ Branch 1 taken 74 times.
14507 if(!swordclk) verifyAWpn();
8988 14507 }
8989
2/2
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 1980933 times.
1981855 if(itemclk>0)
8990 922 --itemclk;
8991
8992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981855 times.
1981855 if(inwallm)
8993 {
8994 attackclk=0;
8995 herostep();
8996
8997 if(CarryHero()==false)
8998 restart_level();
8999
9000 solid_update(false);
9001 return false;
9002 }
9003
9004
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1981854 times.
1981855 if(ewind_restart)
9005 {
9006 1 attackclk=0;
9007 1 restart_level();
9008 1 xofs=0;
9009 1 action=none; FFCore.setHeroAction(none);
9010 1 ewind_restart=false;
9011 1 solid_update(false);
9012 1 return false;
9013 }
9014
9015
2/2
✓ Branch 0 taken 1981177 times.
✓ Branch 1 taken 677 times.
1981854 if(hopclk)
9016 {
9017 677 action=hopping; FFCore.setHeroAction(hopping);
9018 677 }
9019
1/2
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
1981854 if(fallclk)
9020 {
9021 action=falling; FFCore.setHeroAction(falling);
9022 }
9023
9024 1981854 handle_passive_buttons();
9025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981854 times.
1981854 if(liftclk)
9026 {
9027 if(lift_wpn)
9028 {
9029 action=lifting; FFCore.setHeroAction(lifting);
9030 }
9031 else
9032 {
9033 liftclk = 0;
9034 tliftclk = 0;
9035 }
9036 }
9037
1/2
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
1981854 else if(lift_wpn)
9038 {
9039 handle_lift(false);
9040 }
9041
9042
9043 // get user input or do other animation
9044 1981854 freeze_guys=false; // reset this flag, set it again if holding
9045
9046
13/16
✓ Branch 0 taken 1965181 times.
✓ Branch 1 taken 16673 times.
✓ Branch 2 taken 1959961 times.
✓ Branch 3 taken 5220 times.
✓ Branch 4 taken 1959701 times.
✓ Branch 5 taken 260 times.
✓ Branch 6 taken 1959701 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1959701 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1959701 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1951461 times.
✓ Branch 13 taken 8240 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 1951459 times.
1981854 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9047 {
9048 2 holdclk=0;
9049 2 }
9050
9051 1981854 active_shield_id = refreshActiveShield();
9052 1981854 bool sh = active_shield_id > -1;
9053 1981854 itemdata const& shield = itemsbuf[active_shield_id];
9054 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9055 1981854 shield_forcedir = -1;
9056
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1981854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1981854 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9057 {
9058 shield_forcedir = dir;
9059 }
9060
1/2
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
1981854 if(sh != shield_active) //Toggle active shield on/off
9061 {
9062 shield_active = sh;
9063 if(sh) //Toggle active shield on
9064 {
9065 sfx(shield.usesound2); //'Activate' sfx
9066 }
9067 }
9068
9069 1981854 bool isthissolid = false;
9070
9/12
✓ Branch 0 taken 8539 times.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 32227 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21893 times.
✓ Branch 6 taken 1898414 times.
✓ Branch 7 taken 18064 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 677 times.
✓ Branch 10 taken 1588 times.
✗ Branch 11 not taken.
1981854 switch(action)
9071 {
9072 case gothit:
9073
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 17437 times.
18064 if(attackclk)
9074
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 73 times.
700 if(!doattack())
9075 {
9076 73 attackclk=spins=0;
9077 73 tapping=false;
9078 73 }
9079
9080 18064 break;
9081
9082 case drowning:
9083 case lavadrowning:
9084 case sidedrowning:
9085 {
9086 192 herostep(); // maybe this line should be elsewhere?
9087
9088 //!DROWN
9089 // Helpful comment to find drowning -Dimi
9090
9091 192 drop_liftwpn();
9092
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 3 times.
192 if(--drownclk==0)
9093 {
9094 3 action=none; FFCore.setHeroAction(none);
9095 3 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9096 3 int32_t damage = combobuf[water].attributes[0]/10000L;
9097 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9098 3 drownCombo = 0;
9099
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (combobuf[water].type != cWATER) damage = 4;
9100 3 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9101 3 go_respawn_point();
9102 3 hclk=48;
9103 3 }
9104
9105 192 break;
9106 }
9107 case falling:
9108 {
9109 herostep();
9110 pitfall();
9111 break;
9112 }
9113 case freeze:
9114 case sideswimfreeze:
9115 case scrolling:
9116 32227 break;
9117
9118 case casting:
9119 case sideswimcasting:
9120 {
9121 if(magicitem==-1)
9122 {
9123 action=none; FFCore.setHeroAction(none);
9124 }
9125
9126 break;
9127 }
9128 case landhold1:
9129 case landhold2:
9130 {
9131
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 21738 times.
21893 if(--holdclk <= 0)
9132 {
9133 //restart music
9134
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 7 times.
155 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9135 7 playLevelMusic();
9136
9137 155 action=none; FFCore.setHeroAction(none);
9138 155 }
9139 else
9140 21738 freeze_guys=true;
9141
9142 21893 break;
9143 }
9144 case waterhold1:
9145 case waterhold2:
9146 case sidewaterhold1:
9147 case sidewaterhold2:
9148 {
9149 260 diveclk=0;
9150
9151
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 258 times.
260 if(--holdclk <= 0)
9152 {
9153 //restart music
9154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9155 playLevelMusic();
9156
9157 2 SetSwim();
9158 2 }
9159 else
9160 258 freeze_guys=true;
9161
9162 260 break;
9163 }
9164 case hopping:
9165 {
9166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
677 if(DRIEDLAKE)
9167 {
9168 action=none; FFCore.setHeroAction(none);
9169 hopclk = 0;
9170 diveclk = 0;
9171 break;
9172 }
9173
9174 677 do_hopping();
9175 677 break;
9176 }
9177 case inwind:
9178 {
9179 1588 int32_t i=Lwpns.idFirst(wWind);
9180
9181
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 22 times.
1588 if(i<0)
9182 {
9183 22 bool exit=false;
9184
9185
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 if(whirlwind==255)
9186 {
9187 11 exit=true;
9188 11 }
9189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 else if(y<=0 && dir==up) y=-1;
9190
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 else if(y>=160 && dir==down) y=161;
9191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 else if(x<=0 && dir==left) x=-1;
9192
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 else if(x>=240 && dir==right) x=241;
9193 else exit=true;
9194
9195
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 if(exit)
9196 {
9197 11 action=none; FFCore.setHeroAction(none);
9198 11 xofs=0;
9199 11 whirlwind=0;
9200 11 lstep=0;
9201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( dontdraw < 2 ) dontdraw=0;
9202 11 set_respawn_point();
9203 11 }
9204 22 }
9205 /*
9206 else if (((weapon*)Lwpns.spr(i))->dead==1)
9207 {
9208 whirlwind=255;
9209 }
9210 */
9211 else
9212 {
9213 1566 x=Lwpns.spr(i)->x;
9214 1566 y=Lwpns.spr(i)->y;
9215 1566 dir=Lwpns.spr(i)->dir;
9216 }
9217 }
9218 1588 break;
9219 case lifting:
9220 handle_lift();
9221 break;
9222
9223 case sideswimming:
9224 case sideswimattacking:
9225 case sideswimhit:
9226 case swimhit:
9227 case swimming:
9228 {
9229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8539 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8539 if(DRIEDLAKE)
9230 {
9231 action=none; FFCore.setHeroAction(none);
9232 hopclk=0;
9233 break;
9234 }
9235
9236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8539 times.
8539 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9237
9238
4/4
✓ Branch 0 taken 4264 times.
✓ Branch 1 taken 4275 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 4249 times.
8539 if((frame&1) && !shouldbreak)
9239 4249 herostep();
9240
9241
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8539 times.
✓ Branch 4 taken 403 times.
✓ Branch 5 taken 8136 times.
8942 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9242
4/6
✓ Branch 0 taken 8136 times.
✓ Branch 1 taken 403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 403 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 403 times.
8539 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9243
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 403 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 403 times.
403 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9244
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 403 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 403 times.
8539 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9245
2/4
✓ Branch 0 taken 8539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8539 times.
✗ Branch 3 not taken.
8539 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9246 {
9247 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9248 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9249 {
9250 hopclk=0;
9251 diveclk=0;
9252 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9253 else {action=attacking; FFCore.setHeroAction(attacking);}
9254 hopdir=-1;
9255 }
9256 }
9257
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 8509 times.
8539 if (shouldbreak) break;
9258
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8509 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8509 if (action == swimming || action == sideswimming || action == sideswimattacking)
9259 {
9260 8509 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8509 times.
8509 if (combobuf[watercheck].usrflags&cflag2)
9262 {
9263 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9264 {
9265 onpassivedmg = true;
9266 if (damageovertimeclk == 0)
9267 {
9268 int32_t curhp = game->get_life();
9269 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9270 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9271 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9272 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9273 {
9274 hclk = 48;
9275 hitdir = -1;
9276 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9277 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9278 }
9279 }
9280 if (combobuf[watercheck].attribytes[1] > 0)
9281 {
9282 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9283 else --damageovertimeclk;
9284 }
9285 else damageovertimeclk = 0;
9286 }
9287 else damageovertimeclk = 0;
9288 }
9289 8509 else damageovertimeclk = 0;
9290 //combobuf[watercheck].attributes[0]
9291 8509 }
9292
9293 8509 }
9294 [[fallthrough]];
9295 default:
9296 1906923 movehero(); // call the main movement routine
9297 1906923 }
9298
9299
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981854 if(shield_forcedir > -1 && action != rafting)
9300 dir = shield_forcedir;
9301
9302
2/2
✓ Branch 0 taken 1972316 times.
✓ Branch 1 taken 9538 times.
1981854 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9303 9538 set_respawn_point(false); //Keep the 'last safe location' updated!
9304
9305 // check for ladder removal
9306
2/2
✓ Branch 0 taken 9538 times.
✓ Branch 1 taken 1972316 times.
1981854 if(diagonalMovement)
9307 {
9308
1/2
✓ Branch 0 taken 9538 times.
✗ Branch 1 not taken.
9538 if(ladderx+laddery)
9309 {
9310 if(ladderdir==up)
9311 {
9312 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9313 {
9314 reset_ladder();
9315 }
9316 }
9317 else
9318 {
9319 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9320 {
9321 reset_ladder();
9322 }
9323 }
9324 }
9325 9538 }
9326 else
9327 {
9328
4/4
✓ Branch 0 taken 58798 times.
✓ Branch 1 taken 1913518 times.
✓ Branch 2 taken 20216 times.
✓ Branch 3 taken 38582 times.
1972316 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9329 {
9330 1933734 reset_ladder();
9331 1933734 }
9332 }
9333
9334
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1981740 times.
1981854 if(ilswim)
9335 114 landswim++;
9336 1981740 else landswim=0;
9337
9338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981854 times.
1981854 if(hopclk!=0xFF) ilswim=false;
9339
9340
3/4
✓ Branch 0 taken 3529 times.
✓ Branch 1 taken 1978325 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3529 times.
1981854 if((!loaded_guys) && (frame - newscr_clk >= 1))
9341 {
9342
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3527 times.
3529 if(tmpscr->room==rGANON)
9343 {
9344 2 ganon_intro();
9345 2 }
9346 else
9347 {
9348 3527 loadguys();
9349 }
9350 3529 }
9351
9352
2/2
✓ Branch 0 taken 3692 times.
✓ Branch 1 taken 1978162 times.
1981854 if(frame - newscr_clk >= 2)
9353 {
9354 1978162 loadenemies();
9355 1978162 }
9356
9357 // check lots of other things
9358 1981854 checkscroll();
9359
9360
6/8
✓ Branch 0 taken 1980277 times.
✓ Branch 1 taken 1577 times.
✓ Branch 2 taken 1980088 times.
✓ Branch 3 taken 189 times.
✓ Branch 4 taken 1980088 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1980088 times.
1981854 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9361 {
9362 1980088 checkspecial();
9363 1980088 checkitems();
9364 1980088 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9365
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 1970739 times.
1980088 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9366 {
9367 1970739 oldchecklockblock();
9368 1970739 oldcheckbosslockblock();
9369 1970739 }
9370
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 1970739 times.
1980088 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9371 {
9372 1970739 oldcheckchest(cCHEST);
9373 1970739 oldcheckchest(cLOCKEDCHEST);
9374 1970739 oldcheckchest(cBOSSCHEST);
9375 1970739 }
9376 1980088 checkpushblock();
9377 1980088 checkswordtap();
9378
9379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980088 times.
1980088 if(hookshot_frozen==false)
9380 {
9381 1980088 checkspecial2(&lsave);
9382 1980088 }
9383
9384
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1980087 times.
1980088 if(action==won)
9385 {
9386 1 return true;
9387 }
9388 1980087 }
9389
9390 // Somehow Hero was displaced from the fairy flag...
9391
3/6
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 1973613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1981853 if(fairyclk && action != freeze && action != sideswimfreeze)
9392 {
9393 fairyclk = holdclk = refill_why = 0;
9394 }
9395
9396
2/4
✓ Branch 0 taken 1981853 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981853 times.
✗ Branch 3 not taken.
1981853 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9397 {
9398 tmpscr->timedwarptics--;
9399
9400 if(tmpscr->timedwarptics==0)
9401 {
9402 activated_timed_warp=true;
9403
9404 if(tmpscr->flags4 & fTIMEDDIRECT)
9405 {
9406 didpit=true;
9407 pitx=x;
9408 pity=y;
9409 }
9410
9411 int32_t index2 = 0;
9412
9413 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9414
9415 sdir = dir;
9416 dowarp(1,index2);
9417 }
9418 }
9419
9420 1981853 bool awarp = false;
9421 //!DIMI: Global Combo Effects (AUTO STUFF)
9422
2/2
✓ Branch 0 taken 97196 times.
✓ Branch 1 taken 1981853 times.
2079049 for(auto& p : slopes)
9423 {
9424 97196 slope_object& s = p.second;
9425 97196 s.updateslope(); //sets old x/y poses
9426 }
9427
2/2
✓ Branch 0 taken 1981853 times.
✓ Branch 1 taken 348806128 times.
350787981 for(int32_t i=0; i<176; ++i)
9428 {
9429
2/2
✓ Branch 0 taken 1569744 times.
✓ Branch 1 taken 1399933744 times.
1401503488 for(int32_t layer=0; layer<7; ++layer)
9430 {
9431
2/2
✓ Branch 0 taken 1051127616 times.
✓ Branch 1 taken 348806128 times.
1399933744 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9432 1399933744 newcombo const& cmb = combobuf[cid];
9433
9434
2/2
✓ Branch 0 taken 10988208 times.
✓ Branch 1 taken 1388945536 times.
1399933744 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9435 {
9436
2/2
✓ Branch 0 taken 347236384 times.
✓ Branch 1 taken 1041709152 times.
1388945536 if(layer > 2) break;
9437
4/4
✓ Branch 0 taken 347236384 times.
✓ Branch 1 taken 694472768 times.
✓ Branch 2 taken 347127440 times.
✓ Branch 3 taken 108944 times.
1041709152 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9438
4/4
✓ Branch 0 taken 347236384 times.
✓ Branch 1 taken 347345328 times.
✓ Branch 2 taken 108944 times.
✓ Branch 3 taken 347127440 times.
694581712 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9439 347454272 }
9440 358442480 int32_t ind=0;
9441
9442 //AUTOMATIC TRIGGER CODE
9443
1/2
✓ Branch 0 taken 358442480 times.
✗ Branch 1 not taken.
358442480 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9444 {
9445 do_trigger_combo(layer, i);
9446 }
9447
9448 //AUTO WARP CODE
9449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358442480 times.
358442480 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9450 {
9451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358442480 times.
358442480 if(cmb.type==cAWARPA)
9452 {
9453 awarp=true;
9454 ind=0;
9455 }
9456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358442480 times.
358442480 else if(cmb.type==cAWARPB)
9457 {
9458 awarp=true;
9459 ind=1;
9460 }
9461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358442480 times.
358442480 else if(cmb.type==cAWARPC)
9462 {
9463 awarp=true;
9464 ind=2;
9465 }
9466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358442480 times.
358442480 else if(cmb.type==cAWARPD)
9467 {
9468 awarp=true;
9469 ind=3;
9470 }
9471
1/2
✓ Branch 0 taken 358442480 times.
✗ Branch 1 not taken.
358442480 else if(cmb.type==cAWARPR)
9472 {
9473 awarp=true;
9474 ind=zc_oldrand()%4;
9475 }
9476 358442480 }
9477
1/2
✓ Branch 0 taken 358442480 times.
✗ Branch 1 not taken.
358442480 if(awarp)
9478 {
9479 if(tmpscr->flags5&fDIRECTAWARP)
9480 {
9481 didpit=true;
9482 pitx=x;
9483 pity=y;
9484 }
9485
9486 sdir = dir;
9487 dowarp(1,ind);
9488 break;
9489 }
9490 358442480 }
9491
1/2
✓ Branch 0 taken 348806128 times.
✗ Branch 1 not taken.
348806128 if(awarp) break;
9492 348806128 }
9493
9494 1981853 awarp=false;
9495
9496 1981853 word c = tmpscr->numFFC();
9497
2/2
✓ Branch 0 taken 1981853 times.
✓ Branch 1 taken 63264436 times.
65246289 for(word i=0; i<c; i++)
9498 {
9499 63264436 int32_t ind=0;
9500
9501 63264436 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9502
9503
1/2
✓ Branch 0 taken 63264436 times.
✗ Branch 1 not taken.
63264436 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9504 {
9505 do_trigger_combo_ffc(i);
9506 }
9507
9508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63264436 times.
63264436 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9509 {
9510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63264436 times.
63264436 if(cmb.type==cAWARPA)
9511 {
9512 awarp=true;
9513 ind=0;
9514 }
9515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63264436 times.
63264436 else if(cmb.type==cAWARPB)
9516 {
9517 awarp=true;
9518 ind=1;
9519 }
9520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63264436 times.
63264436 else if(cmb.type==cAWARPC)
9521 {
9522 awarp=true;
9523 ind=2;
9524 }
9525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63264436 times.
63264436 else if(cmb.type==cAWARPD)
9526 {
9527 awarp=true;
9528 ind=3;
9529 }
9530
1/2
✓ Branch 0 taken 63264436 times.
✗ Branch 1 not taken.
63264436 else if(cmb.type==cAWARPR)
9531 {
9532 awarp=true;
9533 ind=zc_oldrand()%4;
9534 }
9535 63264436 }
9536
9537
1/2
✓ Branch 0 taken 63264436 times.
✗ Branch 1 not taken.
63264436 if(awarp)
9538 {
9539 if(tmpscr->flags5&fDIRECTAWARP)
9540 {
9541 didpit=true;
9542 pitx=x;
9543 pity=y;
9544 }
9545
9546 sdir = dir;
9547 dowarp(1,ind);
9548 break;
9549 }
9550 63264436 }
9551 1981853 zfix dx, dy;
9552
7/8
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 1975770 times.
✓ Branch 2 taken 3100 times.
✓ Branch 3 taken 2983 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 1970 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1130 times.
1981853 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9553 {
9554
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1103 times.
1130 if (slide_slope(this, dx, dy, slopeid))
9555 {
9556 1103 onplatid = 5;
9557
3/4
✓ Branch 0 taken 809 times.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 809 times.
1103 if (dx || dy) push_move(dx, dy);
9558 1103 }
9559 1130 }
9560
2/2
✓ Branch 0 taken 1980230 times.
✓ Branch 1 taken 1623 times.
1981853 if (onplatid <= 0) slopeid = 0;
9561 1623 else --onplatid;
9562
2/2
✓ Branch 0 taken 1586895 times.
✓ Branch 1 taken 394958 times.
1981853 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9563
5/6
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 1981832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 903 times.
✓ Branch 4 taken 882 times.
✓ Branch 5 taken 1981853 times.
1982735 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9564 {
9565
2/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 882 times.
882 if (check_slope(this, true) && !toogam)
9566 {
9567 882 slope_info const& s = get_slope(this, true).get_info();
9568 882 bool staircheck = false;
9569
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 18 times.
882 if (s.slope() != slopeid && slopeid) staircheck = true;
9570
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 30 times.
882 if (onplatform) staircheck = true;
9571 882 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9572
9573
4/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 36 times.
882 if (dx || dy)
9574 {
9575 846 int32_t pushret = push_move(dx,dy);
9576
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 13 times.
846 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9577
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 2 times.
846 if (s.slope() != slopeid && slopeid) staircheck = true;
9578
2/2
✓ Branch 0 taken 835 times.
✓ Branch 1 taken 11 times.
846 if (onplatform) staircheck = true;
9579
4/4
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 822 times.
846 if(sideview_mode() && slopeid)
9580 822 onplatid = 5;
9581
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if (pushret == 1)
9582 {
9583 dx = -1;
9584 dy = 0;
9585 slope_push_int(s, this, dx, dy, staircheck);
9586 push_move(dx,dy);
9587 }
9588
2/2
✓ Branch 0 taken 839 times.
✓ Branch 1 taken 7 times.
846 if (pushret == 2)
9589 {
9590 7 dx = 0;
9591 7 dy = -1;
9592 7 slope_push_int(s, this, dx, dy, staircheck);
9593 7 push_move(dx,dy);
9594 7 }
9595 846 }
9596 882 }
9597 882 }
9598
9599
1/2
✓ Branch 0 taken 1981853 times.
✗ Branch 1 not taken.
1981853 if(ffwarp)
9600 {
9601 if(ffpit)
9602 {
9603 ffpit=false;
9604 didpit=true;
9605 pitx=x;
9606 pity=y;
9607 }
9608
9609 ffwarp=false;
9610 dowarp(1,0);
9611 }
9612
9613 //Hero->WarpEx
9614
1/2
✓ Branch 0 taken 1981853 times.
✗ Branch 1 not taken.
1981853 if ( FFCore.warpex[wexActive] )
9615 {
9616 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9617 FFCore.warpex[wexActive] = 0;
9618 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9619 for ( int32_t q = 0; q < wexActive; q++ )
9620 {
9621 temp_warpex[q] = FFCore.warpex[q];
9622 FFCore.warpex[q] = 0;
9623 }
9624 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9625 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9626 }
9627
9628 // walk through bombed doors and fake walls
9629 1981853 bool walk=false;
9630 1981853 int32_t dtype=dBOMBED;
9631
9632
2/2
✓ Branch 0 taken 1973627 times.
✓ Branch 1 taken 8226 times.
1981853 if(pushing>=24) dtype=dWALK;
9633
9634
14/18
✓ Branch 0 taken 1514397 times.
✓ Branch 1 taken 467456 times.
✓ Branch 2 taken 1502249 times.
✓ Branch 3 taken 12148 times.
✓ Branch 4 taken 1502249 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1500194 times.
✓ Branch 7 taken 2055 times.
✓ Branch 8 taken 1500025 times.
✓ Branch 9 taken 169 times.
✓ Branch 10 taken 1500025 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1498634 times.
✓ Branch 13 taken 1391 times.
✓ Branch 14 taken 1498634 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1498634 times.
1981853 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9635 {
9636
12/16
✓ Branch 0 taken 6935 times.
✓ Branch 1 taken 1491699 times.
✓ Branch 2 taken 250492 times.
✓ Branch 3 taken 1241207 times.
✓ Branch 4 taken 250492 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 250492 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 50276 times.
✓ Branch 11 taken 200216 times.
✓ Branch 12 taken 14325 times.
✓ Branch 13 taken 35951 times.
✓ Branch 14 taken 14264 times.
✓ Branch 15 taken 61 times.
1498634 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9637 {
9638 61 walk=true;
9639 61 dir=up;
9640 61 }
9641
9642
12/16
✓ Branch 0 taken 6935 times.
✓ Branch 1 taken 1491699 times.
✓ Branch 2 taken 196989 times.
✓ Branch 3 taken 1294710 times.
✓ Branch 4 taken 203924 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 203924 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 25755 times.
✓ Branch 11 taken 178169 times.
✓ Branch 12 taken 6858 times.
✓ Branch 13 taken 18897 times.
✓ Branch 14 taken 6811 times.
✓ Branch 15 taken 47 times.
1498634 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9643 {
9644 47 walk=true;
9645 47 dir=down;
9646 47 }
9647
9648
10/14
✓ Branch 0 taken 6935 times.
✓ Branch 1 taken 1491699 times.
✓ Branch 2 taken 8786 times.
✓ Branch 3 taken 1482913 times.
✓ Branch 4 taken 15721 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15721 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 9006 times.
✓ Branch 11 taken 6715 times.
✓ Branch 12 taken 8966 times.
✓ Branch 13 taken 40 times.
1498634 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9649 {
9650 40 walk=true;
9651 40 dir=left;
9652 40 }
9653
9654
10/14
✓ Branch 0 taken 1491699 times.
✓ Branch 1 taken 6935 times.
✓ Branch 2 taken 12871 times.
✓ Branch 3 taken 1478828 times.
✓ Branch 4 taken 19806 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19806 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12512 times.
✓ Branch 11 taken 7294 times.
✓ Branch 12 taken 12462 times.
✓ Branch 13 taken 50 times.
1498634 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9655 {
9656 50 walk=true;
9657 50 dir=right;
9658 50 }
9659 1498634 }
9660
9661
2/2
✓ Branch 0 taken 1981655 times.
✓ Branch 1 taken 198 times.
1981853 if(walk)
9662 {
9663 198 hclk=0;
9664 198 drawguys=false;
9665
9666
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 52 times.
198 if(dtype==dWALK)
9667 {
9668 52 sfx(tmpscr->secretsfx);
9669 52 }
9670
9671 198 action=none; FFCore.setHeroAction(none);
9672 198 stepforward(29, true);
9673 198 action=scrolling; FFCore.setHeroAction(scrolling);
9674 198 pushing=false;
9675 198 }
9676
9677
4/6
✓ Branch 0 taken 25868 times.
✓ Branch 1 taken 1955985 times.
✓ Branch 2 taken 25868 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25868 times.
1981853 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9678 {
9679
1/2
✓ Branch 0 taken 25868 times.
✗ Branch 1 not taken.
25868 if(heart_beep)
9680 {
9681 25868 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9682 25868 }
9683 else
9684 {
9685 if ( heart_beep_timer == -1 )
9686 {
9687 heart_beep_timer = 70;
9688 }
9689
9690 if ( heart_beep_timer > 0 )
9691 {
9692 --heart_beep_timer;
9693 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9694 }
9695 else
9696 {
9697 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9698 }
9699 }
9700 25868 }
9701 else
9702 {
9703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1955985 times.
1955985 if ( heart_beep_timer > -2 )
9704 {
9705 1955985 heart_beep_timer = -1;
9706 1955985 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9707 1955985 }
9708 }
9709
9710
2/2
✓ Branch 0 taken 1981631 times.
✓ Branch 1 taken 222 times.
1981853 if(rSbtn())
9711 {
9712 222 int32_t tmp_subscr_clk = frame;
9713
9714 222 int32_t save_type = 0;
9715
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
222 switch(lsave)
9716 {
9717 case 0:
9718 {
9719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if( FFCore.runActiveSubscreenScriptEngine() )
9720 {
9721 break;
9722 }
9723
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 221 times.
222 else if ( !stopSubscreenFalling() )
9724 {
9725 221 conveyclk=3;
9726 221 dosubscr(&QMisc);
9727 221 newscr_clk += frame - tmp_subscr_clk;
9728 221 }
9729 220 break;
9730 }
9731
9732
9733 case 2:
9734 save_type = 1;
9735 [[fallthrough]];
9736 case 1:
9737 if(last_savepoint_id)
9738 trigger_save(combobuf[last_savepoint_id]);
9739 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9740 break;
9741 }
9742 220 }
9743
9744
2/2
✓ Branch 0 taken 141603 times.
✓ Branch 1 taken 1840248 times.
1981851 if (!checkstab() )
9745 {
9746 /*
9747 for(int32_t q=0; q<176; q++)
9748 {
9749 set_bit(screengrid,q,0);
9750 }
9751
9752 for(int32_t q=0; q<MAXFFCS; q++)
9753 set_bit(ffcgrid, q, 0);
9754 */
9755 1840248 }
9756
9757 1981851 check_conveyor();
9758 1981851 PhantomsCleanup();
9759 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9760
1/2
✓ Branch 0 taken 1981851 times.
✗ Branch 1 not taken.
1981851 if(attack==wHammer)
9761 {
9762 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9763 {
9764 switch(dir) //Hero's dir
9765 {
9766 case up:
9767 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9768 break;
9769
9770 case down:
9771 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9772 break;
9773
9774 case left:
9775 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9776 break;
9777
9778 case right:
9779 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9780 break;
9781 }
9782
9783 }
9784 }
9785
9786 1981851 handleSpotlights();
9787
9788
2/2
✓ Branch 0 taken 1981541 times.
✓ Branch 1 taken 310 times.
1981851 if(getOnSideviewLadder())
9789 {
9790
5/8
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 304 times.
310 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9791 {
9792 6 setOnSideviewLadder(false);
9793 6 }
9794
6/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 175 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
304 else if(CANFORCEFACEUP)
9795 {
9796 181 setDir(up);
9797 181 }
9798 310 }
9799
9800 1981851 return false;
9801 1981860 }
9802
9803 3307 bool HeroClass::push_pixel(zfix dx, zfix dy)
9804 {
9805
2/4
✓ Branch 0 taken 3307 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3307 times.
✗ Branch 3 not taken.
3307 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9806
3/4
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 2020 times.
✓ Branch 2 taken 1287 times.
✗ Branch 3 not taken.
3307 if(dx && dy)
9807 {
9808 bool r = push_pixel(0,dy);
9809 bool r2 = push_pixel(dx,0);
9810 return r && r2;
9811 }
9812
2/2
✓ Branch 0 taken 1170 times.
✓ Branch 1 taken 2137 times.
3307 if(dx < 0)
9813 {
9814
1/2
✓ Branch 0 taken 1170 times.
✗ Branch 1 not taken.
2340 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9815
1/2
✓ Branch 0 taken 1170 times.
✗ Branch 1 not taken.
1170 || solpush_walkflag(x+dx,y+8,1,this)
9816
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1170 times.
✓ Branch 2 taken 953 times.
✓ Branch 3 taken 217 times.
1170 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9817 {
9818 1170 x += dx;
9819 1170 return true;
9820 }
9821 return false;
9822 }
9823
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 2020 times.
2137 else if(dx > 0)
9824 {
9825
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
234 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9826
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 || solpush_walkflag(x+15+dx,y+8,1,this)
9827
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 56 times.
117 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9828 {
9829 117 x += dx;
9830 117 return true;
9831 }
9832 return false;
9833 }
9834
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 393 times.
2020 else if(dy < 0)
9835 {
9836
2/2
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 12 times.
3242 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9837
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1615 times.
✓ Branch 2 taken 1501 times.
✓ Branch 3 taken 114 times.
1627 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9838 {
9839 1615 y += dy;
9840 1615 return true;
9841 }
9842 12 return false;
9843 }
9844
1/2
✓ Branch 0 taken 393 times.
✗ Branch 1 not taken.
393 else if(dy > 0)
9845 {
9846
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 36 times.
761 if(!(solpush_walkflag(x,y+15+dy,2,this)
9847
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 288 times.
393 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9848 {
9849 357 y += dy;
9850 357 return true;
9851 }
9852 36 return false;
9853 }
9854 return false;
9855 3307 }
9856 1632 int32_t HeroClass::push_move(zfix dx, zfix dy)
9857 {
9858 1632 int32_t ret = 0;
9859
4/4
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 2927 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 2582 times.
4214 while(dx || dy)
9860 {
9861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2582 times.
2582 if(check_pitslide() != -1)
9862 break;
9863
2/2
✓ Branch 0 taken 562 times.
✓ Branch 1 taken 2020 times.
2582 if(dy)
9864 {
9865
2/2
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 17 times.
2020 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
9866 2020 dy -= cy;
9867
2/2
✓ Branch 0 taken 1972 times.
✓ Branch 1 taken 48 times.
2020 if(!push_pixel(0,cy))
9868 {
9869 48 dy = 0;
9870 48 ret |= 2;
9871 48 }
9872 2020 }
9873
2/2
✓ Branch 0 taken 1295 times.
✓ Branch 1 taken 1287 times.
2582 if(dx)
9874 {
9875
2/2
✓ Branch 0 taken 626 times.
✓ Branch 1 taken 661 times.
1287 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
9876 1287 dx -= cx;
9877
1/2
✓ Branch 0 taken 1287 times.
✗ Branch 1 not taken.
1287 if(!push_pixel(cx,0))
9878 {
9879 dx = 0;
9880 ret |= 1;
9881 }
9882 1287 }
9883 }
9884 1632 return ret;
9885 }
9886
9887 1981853 bool HeroClass::setSolid(bool set)
9888 {
9889
1/2
✓ Branch 0 taken 1981853 times.
✗ Branch 1 not taken.
1981853 bool actual = set && !toogam; //not solid when noclipping
9890 1981853 bool ret = solid_object::setSolid(actual);
9891 1981853 solid = set;
9892 1981853 return ret;
9893 }
9894
9895 3851 void HeroClass::solid_push(solid_object* obj)
9896 {
9897
1/2
✓ Branch 0 taken 3851 times.
✗ Branch 1 not taken.
3851 if(obj == this) return; //can't push self
9898
9899 3851 zfix dx, dy;
9900 3851 int32_t hdir = -1;
9901 3851 solid_push_int(obj,dx,dy,hdir);
9902
9903
4/4
✓ Branch 0 taken 3557 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 3366 times.
✓ Branch 3 taken 191 times.
3851 if(!dx && !dy) return;
9904
9905 485 obj->doContactDamage(hdir);
9906
9907 485 bool t = obj->getTempNonsolid();
9908 485 obj->setTempNonsolid(true);
9909
9910 485 push_move(dx,dy);
9911
9912 485 obj->setTempNonsolid(t);
9913 3851 }
9914
9915 // A routine used exclusively by startwpn,
9916 // to switch Hero's weapon if his current weapon (bombs) was depleted.
9917 359 void HeroClass::deselectbombs(int32_t super)
9918 {
9919
5/10
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 359 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 359 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 359 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 359 times.
359 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
9920
2/6
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 359 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
359 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
9921 {
9922
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 359 times.
359 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
9923 359 Bwpn = Bweapon(temp);
9924 359 directItemB = directItem;
9925 359 game->bwpn = temp;
9926 359 }
9927
9928 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
9929 {
9930 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
9931 Xwpn = Bweapon(temp);
9932 directItemX = directItem;
9933 game->xwpn = temp;
9934 }
9935 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
9936 {
9937 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
9938 Ywpn = Bweapon(temp);
9939 directItemY = directItem;
9940 game->ywpn = temp;
9941 }
9942 else
9943 {
9944 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
9945 Awpn = Bweapon(temp);
9946 directItemA = directItem;
9947 game->awpn = temp;
9948 }
9949 359 }
9950
9951 int32_t potion_life=0;
9952 int32_t potion_magic=0;
9953
9954 bool HeroClass::mirrorBonk()
9955 {
9956 zfix tx = x, ty = y, tz = z;
9957 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
9958 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
9959 execute(info);
9960 bool fail = info.isUnwalkable();
9961
9962 if(!fail) //not solid, but check for water/pits...
9963 {
9964 //{ Check water collision.... GAAAAAAAH THIS IS A MESS
9965 int32_t water = 0;
9966 int32_t types[4] = {0};
9967 int32_t x1 = x+4, x2 = x+11,
9968 y1 = y+9, y2 = y+15;
9969 if (get_bit(quest_rules, qr_SMARTER_WATER))
9970 {
9971 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
9972 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
9973 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
9974 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
9975 }
9976 else
9977 {
9978 types[0] = COMBOTYPE(x1,y1);
9979
9980 if(MAPFFCOMBO(x1,y1))
9981 types[0] = FFCOMBOTYPE(x1,y1);
9982
9983 types[1] = COMBOTYPE(x1,y2);
9984
9985 if(MAPFFCOMBO(x1,y2))
9986 types[1] = FFCOMBOTYPE(x1,y2);
9987
9988 types[2] = COMBOTYPE(x2,y1);
9989
9990 if(MAPFFCOMBO(x2,y1))
9991 types[2] = FFCOMBOTYPE(x2,y1);
9992
9993 types[3] = COMBOTYPE(x2,y2);
9994
9995 if(MAPFFCOMBO(x2,y2))
9996 types[3] = FFCOMBOTYPE(x2,y2);
9997
9998 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
9999 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10000 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10001
10002 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10003 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10004 water = typec;
10005 }
10006 if(water > 0)
10007 {
10008 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10009 {
10010 fail = true;
10011 }
10012 }
10013 //}
10014 if(pitslide() || fallclk)
10015 fail = true;
10016 fallclk = 0;
10017 }
10018 x = tx; y = ty; z = tz;
10019 return fail;
10020 }
10021
10022 void HeroClass::doMirror(int32_t mirrorid)
10023 {
10024 if(z > 0 || fakez > 0) return; //No mirror in air
10025 if(mirrorid < 0)
10026 mirrorid = current_item_id(itype_mirror);
10027 if(mirrorid < 0) return;
10028
10029 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10030 {
10031 if(QMisc.miscsfx[sfxERROR])
10032 sfx(QMisc.miscsfx[sfxERROR]);
10033 return;
10034 }
10035 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10036 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10037 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10038 for(auto pos : posarr)
10039 {
10040 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10041 {
10042 if(QMisc.miscsfx[sfxERROR])
10043 sfx(QMisc.miscsfx[sfxERROR]);
10044 return;
10045 }
10046 }
10047
10048 itemdata const& mirror = itemsbuf[mirrorid];
10049 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10050 {
10051 paymagiccost(mirrorid);
10052 if(mirror.usesound2) sfx(mirror.usesound2);
10053
10054 doWarpEffect(mirror.misc2, true);
10055 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10056 {
10057 Quit = qCONT;
10058 skipcont = 1;
10059 }
10060 else //Act as Farore's Wind
10061 {
10062 int32_t nayrutemp=nayruitem;
10063 restart_level();
10064 nayruitem=nayrutemp;
10065 magicitem=-1;
10066 magiccastclk=0;
10067 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10068 }
10069 }
10070 else
10071 {
10072 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10073 int32_t offscr = currscr - DMaps[currdmap].xoff;
10074 if(destdmap < 0)
10075 return;
10076 int32_t destscr = DMaps[destdmap].xoff + offscr;
10077 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10078 return;
10079 paymagiccost(mirrorid);
10080
10081 //Store some values to restore if 'warp fails'
10082 int32_t tLastEntrance = lastentrance,
10083 tLastEntranceDMap = lastentrance_dmap,
10084 tContScr = game->get_continue_scrn(),
10085 tContDMap = game->get_continue_dmap(),
10086 tPortalDMap = game->portalsrcdmap;
10087 int32_t sourcescr = currscr, sourcedmap = currdmap;
10088 zfix tx = x, ty = y, tz = z;
10089 game->portalsrcdmap = -1;
10090 action = none; FFCore.setHeroAction(none);
10091
10092 //Warp to new dmap
10093 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10094 mirror.usesound, 0, -1);
10095
10096 //Check for valid landing location
10097 if(mirrorBonk()) //Invalid landing, warp back!
10098 {
10099 action = none; FFCore.setHeroAction(none);
10100 lastentrance = tLastEntrance;
10101 lastentrance_dmap = tLastEntranceDMap;
10102 game->set_continue_scrn(tContScr);
10103 game->set_continue_dmap(tContDMap);
10104 x = tx;
10105 y = ty;
10106 z = tz;
10107 game->portalsrcdmap = tPortalDMap;
10108 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10109 mirror.usesound, 0, -1);
10110 }
10111 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10112 {
10113 //Place the portal
10114 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10115 //Since it was placed after loading this screen, load the portal object now
10116 game->load_portal();
10117 //Don't immediately trigger the warp back
10118 can_mirror_portal = false;
10119
10120 //Set continue point
10121 if(currdmap != game->get_continue_dmap())
10122 {
10123 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10124 }
10125 game->set_continue_dmap(currdmap);
10126 lastentrance_dmap = currdmap;
10127 lastentrance = game->get_continue_scrn();
10128 }
10129 }
10130 }
10131
10132 1981854 void HeroClass::handle_passive_buttons()
10133 {
10134 1981854 do_liftglove(-1,true);
10135 1981854 do_jump(-1,true);
10136 1981854 }
10137
10138 static bool did_passive_jump = false;
10139 1981895 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10140 {
10141
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1981854 times.
1981895 if(passive) did_passive_jump = false;
10142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 else if(did_passive_jump) return false; //don't jump twice in the same frame
10143
10144
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1981854 times.
1981895 if(jumpid < 0)
10145 1981854 jumpid = current_item_id(itype_rocs,true,true);
10146
10147
2/2
✓ Branch 0 taken 1972935 times.
✓ Branch 1 taken 8960 times.
1981895 if(unsigned(jumpid) >= MAXITEMS) return false;
10148
2/4
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8960 times.
8960 if(inlikelike || charging) return false;
10149
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!checkitem_jinx(jumpid)) return false;
10150
10151 8960 itemdata const& itm = itemsbuf[jumpid];
10152
10153 8960 bool standing = isStanding(true);
10154
3/4
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 7476 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1484 times.
8960 if(!(standing || extra_jump_count < itm.misc1)) return false;
10155
2/4
✓ Branch 0 taken 7476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7476 times.
7476 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10156 {
10157 if(QMisc.miscsfx[sfxERROR])
10158 sfx(QMisc.miscsfx[sfxERROR]);
10159 return false;
10160 }
10161
10162 7476 byte intbtn = byte(itm.misc2&0xFF);
10163
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 7437 times.
7476 if(passive)
10164 {
10165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7437 times.
7437 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10166 7437 return false; //not pressed
10167 }
10168
10169 39 paymagiccost(jumpid);
10170
10171
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(!standing)
10172 {
10173 ++extra_jump_count;
10174 fall = 0;
10175 fakefall = 0;
10176 if(hoverclk > 0)
10177 hoverclk = -hoverclk;
10178 }
10179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(itm.flags & ITEM_FLAG1)
10180 setFall(fall - itm.power);
10181 39 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10182
10183 39 setOnSideviewLadder(false);
10184
10185 // Reset the ladder, unless on an unwalkable combo
10186
3/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
39 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10187 reset_ladder();
10188
10189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(itm.usesound)
10190 39 sfx(itm.usesound,pan(x.getInt()));
10191
10192
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(passive) did_passive_jump = true;
10193 39 return true;
10194 1981895 }
10195 195 void HeroClass::drop_liftwpn()
10196 {
10197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 if(!lift_wpn) return;
10198
10199 handle_lift(false); //sets position properly, accounting for large weapons
10200 auto liftid = current_item_id(itype_liftglove,true,true);
10201 itemdata const& glove = itemsbuf[liftid];
10202 if(glove.flags & ITEM_FLAG1)
10203 {
10204 lift_wpn->z = 0;
10205 lift_wpn->fakez = liftheight;
10206 }
10207 else lift_wpn->z = liftheight;
10208 lift_wpn->dir = dir;
10209 lift_wpn->step = 0;
10210 lift_wpn->fakefall = 0;
10211 lift_wpn->fall = 0;
10212 if(glove.flags & ITEM_FLAG1)
10213 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10214 else
10215 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10216 Lwpns.add(lift_wpn);
10217 lift_wpn = nullptr;
10218 195 }
10219 1981854 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10220 {
10221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981854 times.
1981854 if(liftid < 0)
10222 1981854 liftid = current_item_id(itype_liftglove,true,true);
10223
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 1981235 times.
1981854 if(!can_lift(liftid)) return;
10224 619 itemdata const& glove = itemsbuf[liftid];
10225 619 byte intbtn = byte(glove.misc1&0xFF);
10226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(passive)
10227 {
10228
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 610 times.
619 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10229 610 return; //not pressed
10230 9 }
10231
10232 9 bool had_weapon = lift_wpn;
10233
10234
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10235
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (checkbunny(liftid) && checkmagiccost(liftid))))
10236 {
10237 if(QMisc.miscsfx[sfxERROR])
10238 sfx(QMisc.miscsfx[sfxERROR]);
10239 return;
10240 }
10241
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10242 return;
10243
10244 9 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10245
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(glove.script)
10246 {
10247 if(!paidmagic)
10248 {
10249 paidmagic = true;
10250 paymagiccost(liftid);
10251 }
10252
10253 ri = &(itemScriptData[liftid]);
10254 for ( int32_t q = 0; q < 1024; q++ )
10255 item_stack[liftid][q] = 0xFFFF;
10256 ri->Clear();
10257 item_doscript[liftid] = 1;
10258 itemscriptInitialised[liftid] = 0;
10259 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10260
10261 bool has_weapon = lift_wpn;
10262 if(has_weapon != had_weapon) //Item action script changed the lift information
10263 {
10264 if(passive)
10265 {
10266 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10267 }
10268 return;
10269 }
10270 }
10271
10272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(lift_wpn)
10273 {
10274 if(!paidmagic)
10275 {
10276 paidmagic = true;
10277 paymagiccost(liftid);
10278 }
10279 if(!liftclk)
10280 {
10281 //Throw the weapon!
10282 //hero's direction and position
10283 handle_lift(false); //sets position properly, accounting for large weapons
10284 if(glove.flags & ITEM_FLAG1)
10285 {
10286 lift_wpn->z = 0;
10287 lift_wpn->fakez = liftheight;
10288 }
10289 else lift_wpn->z = liftheight;
10290 lift_wpn->dir = dir;
10291 //Configured throw speed in both axes
10292 lift_wpn->step = zfix(glove.misc2)/100;
10293 if(glove.flags & ITEM_FLAG1)
10294 {
10295 lift_wpn->fakefall = -glove.misc3;
10296 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10297 }
10298 else
10299 {
10300 lift_wpn->fall = -glove.misc3;
10301 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10302 }
10303 Lwpns.add(lift_wpn);
10304 lift_wpn = nullptr;
10305 if(glove.usesound2)
10306 sfx(glove.usesound2,pan(int32_t(x)));
10307 }
10308
10309 if(passive)
10310 {
10311 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10312 }
10313 return;
10314 }
10315
10316 //Check for a liftable combo
10317 9 zfix bx, by;
10318 9 zfix bx2, by2;
10319
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
9 switch(dir)
10320 {
10321 case up:
10322 9 by = y + (bigHitbox ? -2 : 6);
10323 9 by2 = by;
10324 9 bx = x + 4;
10325 9 bx2 = bx + 8;
10326 9 break;
10327 case down:
10328 by = y + 17;
10329 by2 = by;
10330 bx = x + 4;
10331 bx2 = bx + 8;
10332 break;
10333 case left:
10334 by = y + (bigHitbox ? 0 : 8);
10335 by2 = y + 8;
10336 bx = x - 2;
10337 bx2 = x - 2;
10338 break;
10339 case right:
10340 by = y + (bigHitbox ? 0 : 8);
10341 by2 = y + 8;
10342 bx = x + 17;
10343 bx2 = x + 17;
10344 break;
10345 }
10346 9 int32_t pos = COMBOPOS_B(bx,by);
10347 9 int32_t pos2 = COMBOPOS_B(bx2,by2);
10348 9 int32_t foundpos = -1;
10349
10350 9 bool lifted = false;
10351
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
72 for(auto lyr = 6; lyr >= 0; --lyr)
10352 {
10353 63 mapscr* scr = FFCore.tempScreens[lyr];
10354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(pos > -1)
10355 {
10356 63 newcombo const& cmb = combobuf[scr->data[pos]];
10357
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb.liftflags & LF_LIFTABLE)
10358 {
10359 if(do_lift_combo(lyr,pos,liftid))
10360 {
10361 lifted = true;
10362 break;
10363 }
10364 }
10365 63 }
10366
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(pos != pos2 && pos2 > -1)
10367 {
10368 63 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10369
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb2.liftflags & LF_LIFTABLE)
10370 {
10371 if(do_lift_combo(lyr,pos2,liftid))
10372 {
10373 lifted = true;
10374 break;
10375 }
10376 }
10377 63 }
10378 63 }
10379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!lifted) return;
10380 if(!paidmagic)
10381 {
10382 paidmagic = true;
10383 paymagiccost(liftid);
10384 }
10385 if(passive)
10386 {
10387 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10388 }
10389 return;
10390 1981854 }
10391 void HeroClass::handle_lift(bool dec)
10392 {
10393 lift_wpn->fakez = 0;
10394 if(!lift_wpn) liftclk = 0;
10395 if(liftclk <= (dec?1:0))
10396 {
10397 liftclk = 0;
10398 tliftclk = 0;
10399 if(lift_wpn)
10400 {
10401 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10402 {
10403 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10404 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10405 }
10406 else
10407 {
10408 lift_wpn->x = x;
10409 lift_wpn->y = y;
10410 }
10411 lift_wpn->z = liftheight;
10412 }
10413 if(action == lifting)
10414 {
10415 action = none; FFCore.setHeroAction(none);
10416 }
10417 return;
10418 }
10419 if(dec) --liftclk;
10420 double xdist, ydist;
10421 double perc = (liftclk/double(tliftclk));
10422 switch(dir)
10423 {
10424 case up:
10425 {
10426 xdist = 0;
10427 ydist = -16;
10428 if(lift_wpn->txsz > 1)
10429 {
10430 xdist = -((lift_wpn->txsz*8)-8);
10431 }
10432 else xdist = 0;
10433 if(lift_wpn->tysz > 1)
10434 {
10435 ydist = -(lift_wpn->tysz*16);
10436 }
10437 ydist *= perc;
10438 break;
10439 }
10440 case down:
10441 {
10442 xdist = 0;
10443 ydist = 16;
10444 if(lift_wpn->txsz > 1)
10445 {
10446 xdist = -((lift_wpn->txsz*8)-8);
10447 }
10448 else xdist = 0;
10449 ydist *= perc;
10450 break;
10451 }
10452 case left:
10453 {
10454 xdist = -16;
10455 ydist = 0;
10456 if(lift_wpn->txsz > 1)
10457 {
10458 xdist = -(lift_wpn->txsz*16);
10459 }
10460 if(lift_wpn->tysz > 1)
10461 {
10462 ydist = -((lift_wpn->tysz*8)-8);
10463 }
10464 else ydist = 0;
10465 xdist *= perc;
10466 break;
10467 }
10468 case right:
10469 {
10470 xdist = 16;
10471 ydist = 0;
10472 if(lift_wpn->tysz > 1)
10473 {
10474 ydist = -((lift_wpn->tysz*8)-8);
10475 }
10476 else ydist = 0;
10477 xdist *= perc;
10478 break;
10479 }
10480 }
10481
10482 lift_wpn->x = x + xdist;
10483 lift_wpn->y = y + ydist;
10484 lift_wpn->z = liftheight*(1.0-perc);
10485 }
10486 1981854 bool HeroClass::can_lift(int32_t gloveid)
10487 {
10488
2/2
✓ Branch 0 taken 1981235 times.
✓ Branch 1 taken 619 times.
1981854 if(unsigned(gloveid) >= MAXITEMS) return false;
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(lstunclock) return false;
10490
1/2
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
619 if(!checkitem_jinx(gloveid)) return false;
10491 619 itemdata const& glove = itemsbuf[gloveid];
10492
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
619 switch(action)
10493 {
10494 case none: case walking:
10495 619 break;
10496
10497 case swimming:
10498 if(glove.flags & ITEM_FLAG2)
10499 break;
10500 return false;
10501
10502 default:
10503 return false;
10504 }
10505 619 return true;
10506 1981854 }
10507 void HeroClass::lift(weapon* w, byte timer, zfix height)
10508 {
10509 lift_wpn = w;
10510 liftclk = timer;
10511 tliftclk = timer;
10512 if(height < 0)
10513 liftheight = 0;
10514 else liftheight = height;
10515 }
10516
10517 void HeroClass::doSwitchHook(byte style)
10518 {
10519 hs_switcher = true;
10520 pull_hero = true;
10521 //{ Load hook weapons, set them to obey special drawing
10522 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10523 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10524
10525 if(w)
10526 w->switch_hooked = true;
10527 if(hw)
10528 hw->switch_hooked = true;
10529 for(int32_t j=0; j<chainlinks.Count(); j++)
10530 {
10531 chainlinks.spr(j)->switch_hooked = true;
10532 }
10533 //}
10534 if(hooked_combopos > -1)
10535 {
10536 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10537 hooked_layerbits = 0;
10538 for(auto q = 0; q < 7; ++q)
10539 hooked_undercombos[q] = -1;
10540 uint16_t plpos = COMBOPOS(x+8,y+8);
10541 for(auto q = max_layer; q > -1; --q)
10542 {
10543 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10544 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10545 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10546 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10547 bool isPush = false;
10548 if(isSwitchHookable(cmb))
10549 {
10550 if(cmb.type == cSWITCHHOOK)
10551 {
10552 uint16_t plpos = COMBOPOS(x+8,y+8);
10553 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10554 continue; //don't swap with non-zero combo
10555 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10556 continue; //too low a switchhook level
10557 hooked_layerbits |= 1<<q; //Swapping
10558 if(cmb.usrflags&cflag3)
10559 {
10560 if(cmb.usrflags&cflag6)
10561 {
10562 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10563 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10564 }
10565 else
10566 {
10567 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10568 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10569 }
10570 }
10571 else
10572 {
10573 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10574 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10575 isPush = true;
10576 }
10577 }
10578 else if(isCuttableType(cmb.type))
10579 {
10580 if(isCuttableNextType(cmb.type))
10581 {
10582 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10583 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10584 }
10585 else
10586 {
10587 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10588 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10589 }
10590 hooked_layerbits |= 1<<q; //Swapping
10591 }
10592 else
10593 {
10594 hooked_layerbits |= 1<<q; //Swapping
10595 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10596 }
10597 }
10598 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10599 {
10600 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10601 && hasMainGuy())
10602 {
10603 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10604 continue;
10605 }
10606 if(fl1 == mfPUSHED)
10607 {
10608 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10609 continue;
10610 }
10611 if(!isPush) switch(fl1)
10612 {
10613 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10614 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10615 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10616 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10617 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10618 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10619 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10620 isPush = true;
10621 }
10622 if(!isPush) switch(cmb.flag)
10623 {
10624 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10625 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10626 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10627 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10628 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10629 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10630 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10631 isPush = true;
10632 }
10633 if(isPush) //Check for block holes / triggers
10634 {
10635 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10636 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10637 {
10638 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10639 }
10640 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10641 {
10642 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10643 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10644 {
10645 if(lyr == q) continue;
10646 switch(FFCore.tempScreens[q]->sflag[plpos])
10647 {
10648 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10649 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10650 lyr=7;
10651 break;
10652 }
10653 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10654 {
10655 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10656 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10657 lyr=7;
10658 break;
10659 }
10660 }
10661 }
10662 }
10663 }
10664 }
10665 }
10666 switch_hooked = true;
10667 switchhookstyle = style;
10668 switch(style)
10669 {
10670 default: case swPOOF:
10671 {
10672 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10673 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10674 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10675 if(hooked_combopos > -1)
10676 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10677 else if(switching_object)
10678 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10679 break;
10680 }
10681 case swFLICKER:
10682 {
10683 switchhookmaxtime = switchhookclk = 64;
10684 break;
10685 }
10686 case swRISE:
10687 {
10688 switchhookmaxtime = switchhookclk = 64;
10689 break;
10690 }
10691 }
10692 }
10693
10694 11140 bool HeroClass::startwpn(int32_t itemid)
10695 {
10696
1/2
✓ Branch 0 taken 11140 times.
✗ Branch 1 not taken.
11140 if(itemid < 0) return false;
10697 11140 itemdata const& itm = itemsbuf[itemid];
10698
5/6
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 8675 times.
✓ Branch 2 taken 2204 times.
✓ Branch 3 taken 6471 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
11152 if(((dir==up && y<24) || (dir==down && y>128) ||
10699
5/6
✓ Branch 0 taken 3260 times.
✓ Branch 1 taken 3211 times.
✓ Branch 2 taken 3211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 11128 times.
11140 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10700 12 return false;
10701
10702 11128 int32_t wx=x;
10703 11128 int32_t wy=y-fakez;
10704 11128 int32_t wz=z;
10705 11128 bool ret = true;
10706
10707
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
✓ Branch 2 taken 2203 times.
✓ Branch 3 taken 3253 times.
✓ Branch 4 taken 3208 times.
11128 switch(dir)
10708 {
10709 case up:
10710 2464 wy-=16;
10711 2464 break;
10712
10713 case down:
10714 2203 wy+=16;
10715 2203 break;
10716
10717 case left:
10718 3253 wx-=16;
10719 3253 break;
10720
10721 case right:
10722 3208 wx+=16;
10723 3208 break;
10724 }
10725
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11128 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10726
10727
13/27
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 41 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 62 times.
✓ Branch 11 taken 350 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 309 times.
✓ Branch 14 taken 6147 times.
✓ Branch 15 taken 201 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 188 times.
✓ Branch 18 taken 4 times.
✓ Branch 19 taken 3799 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
11128 switch(itm.family)
10728 {
10729 case itype_liftglove:
10730 {
10731 do_liftglove(itemid,false);
10732 dowpn = -1;
10733 ret = false;
10734 break;
10735 }
10736 case itype_potion:
10737 {
10738
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10739 {
10740 if(QMisc.miscsfx[sfxERROR])
10741 sfx(QMisc.miscsfx[sfxERROR]);
10742 return false;
10743 }
10744
10745 13 paymagiccost(itemid);
10746
10747
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(itm.misc1 || itm.misc2)
10748 {
10749 13 refill_what=REFILL_ALL;
10750 13 refill_why=itemid;
10751 13 StartRefill(REFILL_ALL);
10752 13 potion_life = game->get_life();
10753 13 potion_magic = game->get_magic();
10754
10755 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10756 //music_pause();
10757 13 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10758
2/2
✓ Branch 0 taken 3358 times.
✓ Branch 1 taken 13 times.
3371 while(refill())
10759 {
10760 3358 do_refill_waitframe();
10761 }
10762
10763 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10764 //music_resume();
10765 13 ret = false;
10766 13 }
10767
10768 13 break;
10769 }
10770 case itype_bottle:
10771 {
10772 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10773 {
10774 if(QMisc.miscsfx[sfxERROR])
10775 sfx(QMisc.miscsfx[sfxERROR]);
10776 return false;
10777 }
10778 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10779 return false;
10780
10781 size_t bind = game->get_bottle_slot(itm.misc1);
10782 bool paidmagic = false;
10783 if(itm.script)
10784 {
10785 paidmagic = true;
10786 paymagiccost(itemid);
10787
10788 ri = &(itemScriptData[itemid]);
10789 for ( int32_t q = 0; q < 1024; q++ )
10790 item_stack[itemid][q] = 0xFFFF;
10791 ri->Clear();
10792 item_doscript[itemid] = 1;
10793 itemscriptInitialised[itemid] = 0;
10794 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
10795 bind = game->get_bottle_slot(itm.misc1);
10796 }
10797 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
10798 if(bt)
10799 {
10800 word toFill[3] = { 0 };
10801 for(size_t q = 0; q < 3; ++q)
10802 {
10803 char c = bt->counter[q];
10804 if(c > -1)
10805 {
10806 if(bt->flags & (1<<q))
10807 {
10808 toFill[q] = (bt->amount[q]==100)
10809 ? game->get_maxcounter(c)
10810 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
10811 }
10812 else toFill[q] = bt->amount[q];
10813 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
10814 {
10815 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
10816 }
10817 }
10818 }
10819 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
10820 bool run = max > 0;
10821 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
10822 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
10823 else
10824 {
10825 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
10826 run = true;
10827 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
10828 run = true;
10829 }
10830 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
10831 {
10832 if(bt->flags & BTFLAG_CURESWJINX)
10833 {
10834 swordclk = 0;
10835 verifyAWpn();
10836 }
10837 if(bt->flags & BTFLAG_CUREITJINX)
10838 itemclk = 0;
10839 if(!paidmagic)
10840 paymagiccost(itemid);
10841 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10842 sfx(itm.usesound,pan(x.getInt()));
10843 for(size_t q = 0; q < 20; ++q)
10844 do_refill_waitframe();
10845 double inc = max/60.0; //1 second
10846 double xtra[3]{ 0 };
10847 for(size_t q = 0; q < 60; ++q)
10848 {
10849 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
10850 sfx(QMisc.miscsfx[sfxREFILL]);
10851 for(size_t j = 0; j < 3; ++j)
10852 {
10853 xtra[j] += inc;
10854 word f = floor(xtra[j]);
10855 xtra[j] -= f;
10856 if(toFill[j] > f)
10857 {
10858 toFill[j] -= f;
10859 game->change_counter(f,bt->counter[j]);
10860 }
10861 else if(toFill[j])
10862 {
10863 game->change_counter(toFill[j],bt->counter[j]);
10864 toFill[j] = 0;
10865 }
10866 }
10867 do_refill_waitframe();
10868 }
10869 for(size_t j = 0; j < 3; ++j)
10870 {
10871 if(toFill[j])
10872 {
10873 game->change_counter(toFill[j],bt->counter[j]);
10874 toFill[j] = 0;
10875 }
10876 }
10877 for(size_t q = 0; q < 20; ++q)
10878 do_refill_waitframe();
10879 game->set_bottle_slot(itm.misc1, bt->next_type);
10880 }
10881 }
10882
10883 dowpn = -1;
10884 ret = false;
10885 break;
10886 }
10887
10888 case itype_note:
10889 {
10890 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10891 {
10892 if(QMisc.miscsfx[sfxERROR])
10893 sfx(QMisc.miscsfx[sfxERROR]);
10894 return false;
10895 }
10896 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
10897 {
10898 sfx(itm.usesound);
10899 donewmsg(itm.misc1);
10900 paymagiccost(itemid);
10901 }
10902 dowpn = -1;
10903 ret = false;
10904 break;
10905 }
10906
10907 case itype_mirror:
10908 doMirror(itemid);
10909 if(Quit)
10910 return false;
10911 ret = false;
10912 break;
10913
10914 case itype_rocs:
10915 {
10916
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2 times.
41 if(!do_jump(itemid,false)) return false;
10917 39 ret = false;
10918 }
10919 39 break;
10920
10921 case itype_letter:
10922 {
10923
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 if(current_item(itype_letter)==i_letter &&
10924
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].room==rP_SHOP &&
10925
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].guy &&
10926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
10927
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
10928 3 checkbunny(itemid)
10929 )
10930 {
10931 3 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
10932
10933
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(usedid != -1)
10934 3 getitem(usedid, true, true);
10935
10936 3 sfx(tmpscr[currscr<128?0:1].secretsfx);
10937 3 setupscreen();
10938 3 action=none; FFCore.setHeroAction(none);
10939 3 }
10940
10941 3 ret = false;
10942 }
10943 3 break;
10944
10945 case itype_whistle:
10946 {
10947 bool whistleflag;
10948
10949
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10950 {
10951 if(QMisc.miscsfx[sfxERROR])
10952 sfx(QMisc.miscsfx[sfxERROR]);
10953 return false;
10954 }
10955
10956 62 paymagiccost(itemid);
10957 62 sfx(itm.usesound);
10958
10959
4/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 30 times.
62 if(dir==up || dir==right)
10960 32 ++blowcnt;
10961 else
10962 30 --blowcnt;
10963
10964 62 int sfx_count = 0;
10965
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11222 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11222 times.
✓ Branch 6 taken 11160 times.
✓ Branch 7 taken 62 times.
11222 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
10966 {
10967 11160 sfx_count += 1;
10968 11160 advanceframe(true);
10969
10970
1/2
✓ Branch 0 taken 11160 times.
✗ Branch 1 not taken.
11160 if(Quit)
10971 return false;
10972 }
10973
10974
7/14
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 62 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 62 times.
✗ Branch 13 not taken.
62 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
10975
10976
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
10977 3 didstuff |= did_whistle;
10978
10979
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
62 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
10980 3 return false;
10981
10982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
10983
10984
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
59 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
10985
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 || (tmpscr->flags7&fWHISTLEPAL))
10986 {
10987 20 whistleclk=0; // signal to start drying lake or doing other stuff
10988 20 }
10989 else
10990 {
10991 39 int32_t where = itm.misc1;
10992
10993
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(where>right) where=dir^1;
10994
10995
4/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
54 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
10996
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
10997
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
30 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
10998
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
15 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
10999
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 (zfix)0,
11000 wWind,
11001 0, //type
11002 0,
11003 15 where,
11004
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11005
11006 39 whistleitem=itemid;
11007 }
11008
11009 59 ret = false;
11010 }
11011 59 break;
11012
11013 case itype_bomb:
11014 {
11015 //Remote detonation
11016
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 350 times.
350 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11017 {
11018 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11019
11020 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11021 {
11022 //If this ever needs a version check, in the future. -z
11023 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11024 {
11025 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11026 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11027 }
11028 ew->misc=50;
11029 ew->clk=ew->misc-3;
11030 ew->id=wBomb;
11031 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11032 }
11033
11034 deselectbombs(false);
11035 return false;
11036 }
11037
11038
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 350 times.
350 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11039 {
11040 if(QMisc.miscsfx[sfxERROR])
11041 sfx(QMisc.miscsfx[sfxERROR]);
11042 return false;
11043 }
11044
11045 350 paymagiccost(itemid);
11046
11047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(itm.misc1>0) // If not remote bombs
11048 350 deselectbombs(false);
11049
11050
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 327 times.
350 if(isdungeon())
11051 {
11052
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 26 times.
327 wy=zc_max(wy,16);
11053 327 }
11054
11055
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
700 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11056
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11057 350 sfx(WAV_PLACE,pan(wx));
11058 }
11059 350 break;
11060
11061 case itype_sbomb:
11062 {
11063 //Remote detonation
11064
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11065 {
11066 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11067
11068 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11069 {
11070 ew->misc=50;
11071 ew->clk=ew->misc-3;
11072 ew->id=wSBomb;
11073 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11074 }
11075
11076 deselectbombs(true);
11077 return false;
11078 }
11079
11080
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11081 {
11082 if(QMisc.miscsfx[sfxERROR])
11083 sfx(QMisc.miscsfx[sfxERROR]);
11084 return false;
11085 }
11086
11087 9 paymagiccost(itemid);
11088
11089
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itm.misc1>0) // If not remote bombs
11090 9 deselectbombs(true);
11091
11092
6/12
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
9 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true));
11093 9 sfx(WAV_PLACE,pan(wx));
11094 }
11095 9 break;
11096
11097 case itype_wand:
11098 {
11099
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 200 times.
309 if(Lwpns.idCount(wMagic))
11100 {
11101 109 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11102 109 return false;
11103 }
11104
11105 200 int32_t bookid = current_item_id(itype_book);
11106
3/4
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 139 times.
200 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11107
11108
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11109 {
11110 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11111 return false;
11112 }
11113
11114
3/6
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200 times.
✗ Branch 5 not taken.
200 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11115 {
11116 if(QMisc.miscsfx[sfxERROR])
11117 sfx(QMisc.miscsfx[sfxERROR]);
11118 return false;
11119 }
11120
11121
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2 times.
200 if(Lwpns.idCount(wBeam))
11122 2 Lwpns.del(Lwpns.idFirst(wBeam));
11123
11124 int32_t type, pow;
11125
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 98 times.
200 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11126 {
11127
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 61 times.
102 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11128
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 61 times.
102 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11129 102 }
11130 else
11131 {
11132
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11133
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11134 }
11135
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 400 times.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 200 times.
400 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
400 if(dir!=(i^1))
11137 {
11138
5/10
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 200 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 200 times.
✗ Branch 9 not taken.
200 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11139
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 139 times.
200 if(paybook)
11140 139 magic->linkedItem = bookid;
11141 //magic->dir = this->dir; //Save player dir for special weapons.
11142 200 Lwpns.add(magic);
11143 200 }
11144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11145 200 paymagiccost(itemid);
11146 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11147
11148
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 139 times.
200 if(paybook)
11149 139 paymagiccost(current_item_id(itype_book));
11150
11151
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 61 times.
200 if(bookid != -1)
11152 {
11153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11154 {
11155 sfx(itemsbuf[bookid].misc2,pan(wx));
11156 }
11157 else
11158 {
11159 139 sfx(itm.usesound,pan(wx));
11160 }
11161 139 }
11162 else
11163 61 sfx(itm.usesound,pan(wx));
11164 }
11165 /*
11166 // Fireball Wand
11167 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11168 switch (dir)
11169 {
11170 case up:
11171 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11172 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11173 break;
11174 case down:
11175 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11176 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11177 break;
11178 case left:
11179 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11180 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11181 break;
11182 case right:
11183 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11184 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11185 break;
11186 }
11187 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11188 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11189 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11190 */
11191 200 break;
11192
11193 case itype_sword:
11194 {
11195
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6147 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11196 {
11197 if(QMisc.miscsfx[sfxERROR])
11198 sfx(QMisc.miscsfx[sfxERROR]);
11199 return false;
11200 }
11201
11202
4/4
✓ Branch 0 taken 1126 times.
✓ Branch 1 taken 5021 times.
✓ Branch 2 taken 1126 times.
✓ Branch 3 taken 5021 times.
6147 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11203 {
11204 1126 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11205 1126 return false;
11206 }
11207
11208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5021 times.
5021 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11209 5021 paymagiccost(itemid);
11210 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11211 float temppower;
11212
11213
1/2
✓ Branch 0 taken 5021 times.
✗ Branch 1 not taken.
5021 if(itm.flags & ITEM_FLAG2)
11214 {
11215 5021 temppower=game->get_hero_dmgmult()*itm.power;
11216 5021 temppower=temppower*itm.misc2;
11217 5021 temppower=temppower/100;
11218 5021 }
11219 else
11220 {
11221 temppower = game->get_hero_dmgmult()*itm.misc2;
11222 }
11223
11224 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11225 //Add weapon script to sword beams.
11226
5/10
✓ Branch 0 taken 5021 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5021 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5021 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5021 times.
✗ Branch 9 not taken.
5021 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11227 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11228 //w->weaponscript = itm.weaponscript;
11229 //w->canrunscript = 0;
11230 5021 sfx(WAV_BEAM,pan(wx));
11231 }
11232 5021 break;
11233
11234 case itype_candle:
11235 {
11236 201 int32_t countid = itemid;
11237
1/2
✓ Branch 0 taken 201 times.
✗ Branch 1 not taken.
201 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11238 201 countid = -itype_candle;
11239
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 192 times.
201 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11240 {
11241 9 return false;
11242 }
11243
11244
3/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 185 times.
192 if(Lwpns.idCount(wFire) >= (itm.misc3 < 1 ? 2 : itm.misc3))
11245 {
11246 7 return false;
11247 }
11248
11249
2/4
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
185 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11250 {
11251 if(QMisc.miscsfx[sfxERROR])
11252 sfx(QMisc.miscsfx[sfxERROR]);
11253 return false;
11254 }
11255
11256 185 paymagiccost(itemid);
11257
11258
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 92 times.
185 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11259
11260
4/8
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 185 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 185 times.
✗ Branch 7 not taken.
370 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11261 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11262 185 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11263
2/4
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
185 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11264 185 sfx(itm.usesound,pan(wx));
11265 185 attack=wFire;
11266 }
11267 185 break;
11268
11269 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11270 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11271 {
11272 int32_t wtype = wScript1 + (itm.family-itype_script1);
11273 if(Lwpns.idCount(wtype))
11274 return false;
11275
11276 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11277 {
11278 if(QMisc.miscsfx[sfxERROR])
11279 sfx(QMisc.miscsfx[sfxERROR]);
11280 return false;
11281 }
11282
11283 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11284 paymagiccost(itemid);
11285
11286 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11287 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1;
11288 sfx(itm.usesound,pan(wx));
11289 }
11290 break;
11291
11292 case itype_icerod:
11293 {
11294 if(Lwpns.idCount(wIce))
11295 return false;
11296
11297 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11298 {
11299 if(QMisc.miscsfx[sfxERROR])
11300 sfx(QMisc.miscsfx[sfxERROR]);
11301 return false;
11302 }
11303
11304 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11305 paymagiccost(itemid);
11306
11307 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11308 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1;
11309 sfx(itm.usesound,pan(wx));
11310 }
11311 break;
11312
11313 case itype_arrow:
11314 {
11315
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 183 times.
188 if(Lwpns.idCount(wArrow) > itm.misc2)
11316 5 return false;
11317
11318
2/4
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 183 times.
183 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11319 {
11320 if(QMisc.miscsfx[sfxERROR])
11321 sfx(QMisc.miscsfx[sfxERROR]);
11322 return false;
11323 }
11324
11325 183 paymagiccost(itemid);
11326
11327
6/12
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 183 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 183 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 183 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 183 times.
✗ Branch 11 not taken.
183 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11328 183 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11329 183 sfx(itm.usesound,pan(wx));
11330 }
11331 183 break;
11332
11333 case itype_bait:
11334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11335 return false;
11336
11337
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11338 {
11339 if(QMisc.miscsfx[sfxERROR])
11340 sfx(QMisc.miscsfx[sfxERROR]);
11341 return false;
11342 }
11343
11344 4 paymagiccost(itemid);
11345 4 sfx(itm.usesound,pan(wx));
11346
11347
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
11348 {
11349
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,iBait,ipDUMMY+ipFADE,0));
11350 4 fadeclk=66;
11351 4 dismissmsg();
11352 4 clear_bitmap(pricesdisplaybuf);
11353 4 set_clip_state(pricesdisplaybuf, 1);
11354 // putscr(scrollbuf,0,0,tmpscr);
11355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11356 4 removeItemsOfFamily(game,itemsbuf,itype_bait);
11357 4 verifyBothWeapons();
11358 4 sfx(tmpscr->secretsfx);
11359 4 return false;
11360 }
11361
11362 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11363 break;
11364
11365 case itype_brang:
11366 {
11367
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 3712 times.
3799 if(Lwpns.idCount(wBrang) > itm.misc2)
11368 87 return false;
11369
11370
2/4
✓ Branch 0 taken 3712 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3712 times.
3712 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11371 {
11372 if(QMisc.miscsfx[sfxERROR])
11373 sfx(QMisc.miscsfx[sfxERROR]);
11374 return false;
11375 }
11376
11377 3712 paymagiccost(itemid);
11378 3712 current_item_power(itype_brang);
11379
6/12
✓ Branch 0 taken 3712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3712 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3712 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3712 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3712 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3712 times.
✗ Branch 11 not taken.
3712 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11380 }
11381 3712 break;
11382
11383 case itype_hookshot:
11384 case itype_switchhook:
11385 {
11386 if(inlikelike || Lwpns.idCount(wHookshot))
11387 return false;
11388
11389 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11390 {
11391 if(QMisc.miscsfx[sfxERROR])
11392 sfx(QMisc.miscsfx[sfxERROR]);
11393 return false;
11394 }
11395 bool sw = itm.family == itype_switchhook;
11396
11397 if(sw && (itm.flags&ITEM_FLAG8))
11398 switchhook_cost_item = itemid;
11399 else paymagiccost(itemid);
11400
11401 bool use_hookshot=true;
11402 bool hit_hs = false, hit_solid = false, insta_switch = false;
11403 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11404 int32_t cpos = -1, ffcpos = -1;
11405 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11406 {
11407 if(dir==up)
11408 {
11409 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11410 hit_hs = true;
11411 }
11412 else if(dir==down)
11413 {
11414 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11415 hit_hs = true;
11416 }
11417 else if(dir==left)
11418 {
11419 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11420 hit_hs = true;
11421 }
11422 else if(dir==right)
11423 {
11424 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11425 hit_hs = true;
11426 }
11427 //Diagonal Hookshot (6)
11428 else if(dir==r_down)
11429 {
11430 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11431 hit_hs = true;
11432 }
11433 else if(dir==l_down)
11434 {
11435 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11436 hit_hs = true;
11437 }
11438 else if(dir==r_up)
11439 {
11440 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11441 hit_hs = true;
11442 }
11443 else if(dir==l_up)
11444 {
11445 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11446 hit_hs = true;
11447 }
11448 }
11449 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11450 hit_solid = true;
11451 if(hit_hs)
11452 {
11453 if(sw)
11454 insta_switch = true; //switch immediately
11455 else use_hookshot = false; //No hooking against grabbable
11456 }
11457 if(hit_solid && !insta_switch)
11458 use_hookshot = false;
11459 if(use_hookshot)
11460 {
11461 int32_t hookitem = itm.fam_type;
11462 int32_t hookpower = itm.power;
11463 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11464
11465 if(!Lwpns.has_space())
11466 {
11467 Lwpns.del(0);
11468 }
11469
11470 if(!Lwpns.has_space(2))
11471 {
11472 Lwpns.del(0);
11473 }
11474
11475 switch(dir)
11476 {
11477 case up:
11478 {
11479 hookshot_used=true;
11480 hs_switcher = sw;
11481 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11482 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11483 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11484 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11485 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11486 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11487 hs_startx=wx;
11488 hs_starty=wy-4;
11489 }
11490 break;
11491
11492 case down:
11493 {
11494 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11495 hookshot_used=true;
11496 hs_switcher = sw;
11497 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11498 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11499 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11500 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11501 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11502 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11503 hs_startx=wx;
11504 hs_starty=wy;
11505 }
11506 break;
11507
11508 case left:
11509 {
11510 hookshot_used=true;
11511 hs_switcher = sw;
11512 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11513 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11514 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11515 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11516 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11517 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11518 hs_startx=wx-4;
11519 hs_starty=wy;
11520 }
11521 break;
11522
11523 case right:
11524 {
11525 hookshot_used=true;
11526 hs_switcher = sw;
11527 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11528 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11529 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11530 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11531 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11532 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11533 hs_startx=wx+4;
11534 hs_starty=wy;
11535 }
11536 break;
11537 //Diagonal Hookshot (7)
11538 case r_down:
11539 {
11540 hookshot_used=true;
11541 hs_switcher = sw;
11542 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11543 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11544 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11545 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11546 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11547 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11548 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11549 hs_startx=wx+4;
11550 hs_starty=wy;
11551 }
11552 break;
11553
11554 case r_up:
11555 {
11556 hookshot_used=true;
11557 hs_switcher = sw;
11558 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11559 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11560 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11561 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11562 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11563 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11564 hs_startx=wx+4;
11565 hs_starty=wy;
11566 }
11567 break;
11568
11569 case l_down:
11570 {
11571 hookshot_used=true;
11572 hs_switcher = sw;
11573 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11574 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11575 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11576 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11577 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11578 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11579 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11580 hs_startx=wx+4;
11581 hs_starty=wy;
11582 }
11583 break;
11584
11585 case l_up:
11586 {
11587 hookshot_used=true;
11588 hs_switcher = sw;
11589 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11590 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11591 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11592 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11593 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11594 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11595 hs_startx=wx+4;
11596 hs_starty=wy;
11597 }
11598 break;
11599 }
11600 hookshot_frozen=true;
11601 }
11602 if(insta_switch)
11603 {
11604 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11605 if (cpos > -1) hooked_combopos = cpos;
11606 if (ffcpos > -1)
11607 {
11608 switching_object = &(tmpscr->ffcs[ffcpos]);
11609 switching_object->switch_hooked = true;
11610 }
11611 w->misc=2;
11612 w->step=0;
11613 doSwitchHook(itm.misc5);
11614 if(itm.usesound2)
11615 sfx(itm.usesound2,pan(int32_t(x)));
11616 else if(QMisc.miscsfx[sfxSWITCHED])
11617 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11618 stop_sfx(itm.usesound);
11619 }
11620 }
11621 break;
11622
11623 case itype_dinsfire:
11624 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11625 return false;
11626
11627 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11628 {
11629 if(QMisc.miscsfx[sfxERROR])
11630 sfx(QMisc.miscsfx[sfxERROR]);
11631 return false;
11632 }
11633
11634 paymagiccost(itemid);
11635 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11636 else {action=casting; FFCore.setHeroAction(casting);}
11637 magicitem=itemid;
11638 break;
11639
11640 case itype_faroreswind:
11641 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11642 return false;
11643
11644 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11645 {
11646 if(QMisc.miscsfx[sfxERROR])
11647 sfx(QMisc.miscsfx[sfxERROR]);
11648 return false;
11649 }
11650
11651 paymagiccost(itemid);
11652 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11653 else {action=casting; FFCore.setHeroAction(casting);}
11654 magicitem=itemid;
11655 break;
11656
11657 case itype_nayruslove:
11658 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11659 return false;
11660
11661 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11662 {
11663 if(QMisc.miscsfx[sfxERROR])
11664 sfx(QMisc.miscsfx[sfxERROR]);
11665 return false;
11666 }
11667
11668 paymagiccost(itemid);
11669 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11670 else {action=casting; FFCore.setHeroAction(casting);}
11671 magicitem=itemid;
11672 break;
11673
11674 case itype_cbyrna:
11675 {
11676 //Beams already deployed
11677 if(Lwpns.idCount(wCByrna))
11678 {
11679 stopCaneOfByrna();
11680 return false;
11681 }
11682
11683 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11684 {
11685 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11686 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11687 return false;
11688 }
11689
11690 paymagiccost(itemid);
11691 last_cane_of_byrna_item_id = itemid;
11692 //zprint("itm.misc3: %d\n", itm.misc3);
11693 for(int32_t i=0; i<itm.misc3; i++)
11694 {
11695 //byrna weapons are added here
11696 //space them apart
11697 //zprint("Added byrna weapon %d.\n", i);
11698 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11699 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11700 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11701 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11702 //wx += cos(2 * PI / (itm.misc3-i));
11703 //wy += sin(2 * PI / (itm.misc3-i));
11704 }
11705 if(!(Lwpns.idCount(wCByrna)))
11706 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11707 }
11708 break;
11709
11710 case itype_clock:
11711 {
11712 ret = false;
11713 if(!(itm.flags & ITEM_FLAG1))
11714 break; //Passive clock, don't use
11715 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11716 break;
11717 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11718 {
11719 if(QMisc.miscsfx[sfxERROR])
11720 sfx(QMisc.miscsfx[sfxERROR]);
11721 return false;
11722 }
11723
11724 paymagiccost(itemid);
11725
11726 setClock(watch=true);
11727
11728 for(int32_t i=0; i<eMAXGUYS; i++)
11729 clock_zoras[i]=0;
11730
11731 clockclk=itm.misc1;
11732 sfx(itm.usesound);
11733 break;
11734 }
11735 case itype_killem:
11736 {
11737 ret = false;
11738 if(!(itm.flags & ITEM_FLAG1))
11739 break; //Passive killemall, don't use
11740
11741 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11742 || !can_kill_em_all()) //No enemies onscreen
11743 {
11744 if(QMisc.miscsfx[sfxERROR])
11745 sfx(QMisc.miscsfx[sfxERROR]);
11746 return false;
11747 }
11748
11749 paymagiccost(itemid);
11750
11751 kill_em_all();
11752 sfx(itm.usesound);
11753 break;
11754 }
11755 case itype_refill:
11756 {
11757 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11758 {
11759 if(QMisc.miscsfx[sfxERROR])
11760 sfx(QMisc.miscsfx[sfxERROR]);
11761 return false;
11762 }
11763
11764 bool did_something = false;
11765
11766 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
11767 {
11768 if(swordclk)
11769 did_something = true;
11770 swordclk = 0;
11771 verifyAWpn();
11772 }
11773 for(auto q = 0; q < 5; ++q)
11774 {
11775 auto ctr = itm.misc(q);
11776 if(unsigned(ctr) >= MAX_COUNTERS)
11777 continue;
11778 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
11779 if(!amnt) continue;
11780 bool gradual = itm.flags & ITEM_FLAG2;
11781 if(amnt > 0)
11782 {
11783 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
11784 {
11785 //Can't *do* anything... skip
11786 continue;
11787 }
11788 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
11789 {
11790 //Can't do anything unless affecting dcounter
11791 gradual = true;
11792 }
11793 }
11794 else //Negative
11795 {
11796 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
11797 {
11798 //Can't *do* anything... skip
11799 continue;
11800 }
11801 if(game->get_counter(ctr) <= 0)
11802 {
11803 //Can't do anything unless affecting dcounter
11804 gradual = true;
11805 }
11806 }
11807 did_something = true;
11808 if(gradual) //Gradual
11809 {
11810 game->change_dcounter(amnt, ctr);
11811 }
11812 else
11813 {
11814 game->change_counter(amnt, ctr);
11815 }
11816 }
11817 if(!did_something)
11818 {
11819 if(QMisc.miscsfx[sfxERROR])
11820 sfx(QMisc.miscsfx[sfxERROR]);
11821 return false;
11822 }
11823 paymagiccost(itemid);
11824 sfx(itm.usesound);
11825 ret = false;
11826 break;
11827 }
11828
11829 default:
11830 2 ret = false;
11831 2 }
11832
11833
2/2
✓ Branch 0 taken 9763 times.
✓ Branch 1 taken 13 times.
9776 if(itm.flags & ITEM_DOWNGRADE)
11834 {
11835 13 game->set_item(itemid,false);
11836
11837 // Maybe Item Override has allowed the same item in both slots?
11838
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Bwpn == itemid)
11839 {
11840 Bwpn = 0;
11841 game->forced_bwpn = -1;
11842 verifyBWpn();
11843 }
11844
11845
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Awpn == itemid)
11846 {
11847 Awpn = 0;
11848 game->forced_awpn = -1;
11849 verifyAWpn();
11850 }
11851
11852
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Xwpn == itemid)
11853 {
11854 Xwpn = 0;
11855 game->forced_xwpn = -1;
11856 verifyXWpn();
11857 }
11858
11859
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Ywpn == itemid)
11860 {
11861 Ywpn = 0;
11862 game->forced_ywpn = -1;
11863 verifyYWpn();
11864 }
11865 13 }
11866
11867 9776 return ret;
11868 11140 }
11869
11870
11871 367735 bool HeroClass::doattack()
11872 {
11873 //int32_t s = BSZ ? 0 : 11;
11874 367735 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
11875
11876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 367735 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
367735 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
11877
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 367735 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
367735 if(attack==wBugNet && bugnetid!=-1)
11878 {
11879 if(++attackclk >= NET_CLK_TOTAL)
11880 return false;
11881
11882 return true;
11883 }
11884
11885 // Abort attack if attackclk has run out and:
11886 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
11887 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
11888
11889
4/6
✓ Branch 0 taken 20190 times.
✓ Branch 1 taken 347545 times.
✓ Branch 2 taken 20190 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 459 times.
368194 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
11890
8/12
✓ Branch 0 taken 17110 times.
✓ Branch 1 taken 3080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17110 times.
✓ Branch 4 taken 19881 times.
✓ Branch 5 taken 309 times.
✓ Branch 6 taken 19731 times.
✓ Branch 7 taken 150 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 459 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
20190 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
11891 {
11892 20190 tapping=false;
11893 20190 return false;
11894 }
11895
11896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 347545 times.
347545 if(attackclk>29)
11897 {
11898 tapping=false;
11899 return false;
11900 }
11901
11902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 347545 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
347545 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
11903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 347545 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
347545 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
11904 // An attack can be "walked out-of" after 8 frames, unless it's:
11905 // * a sword stab
11906 // * a hammer pound
11907 // * a wand thrust
11908 // * a candle thrust
11909 // * a cane thrust
11910 // In which case it should continue.
11911
8/8
✓ Branch 0 taken 16490 times.
✓ Branch 1 taken 331055 times.
✓ Branch 2 taken 41106 times.
✓ Branch 3 taken 24616 times.
✓ Branch 4 taken 309728 times.
✓ Branch 5 taken 45943 times.
✓ Branch 6 taken 64807 times.
✓ Branch 7 taken 244921 times.
412352 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
11912
4/6
✓ Branch 0 taken 64807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2472 times.
✓ Branch 3 taken 62335 times.
✓ Branch 4 taken 2472 times.
✗ Branch 5 not taken.
64807 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
11913
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64807 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
11914
2/2
✓ Branch 0 taken 64807 times.
✓ Branch 1 taken 2472 times.
62335 && (attack != wBugNet) && attackclk>7))
11915 {
11916
8/8
✓ Branch 0 taken 22746 times.
✓ Branch 1 taken 955 times.
✓ Branch 2 taken 21937 times.
✓ Branch 3 taken 809 times.
✓ Branch 4 taken 20829 times.
✓ Branch 5 taken 1108 times.
✓ Branch 6 taken 996 times.
✓ Branch 7 taken 19833 times.
105913 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
11917 {
11918 3868 lstep = s;
11919 3868 return false;
11920 }
11921 19833 }
11922
11923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
315641 if(charging==0)
11924 {
11925 315641 lstep=0;
11926 315641 }
11927
11928 // Work out the sword charge-up delay
11929 315641 int32_t magiccharge = 192, normalcharge = 64;
11930 315641 int32_t itemid = current_item_id(itype_chargering);
11931
11932
1/2
✓ Branch 0 taken 315641 times.
✗ Branch 1 not taken.
315641 if(itemid>=0)
11933 {
11934 normalcharge = itemsbuf[itemid].misc1;
11935 magiccharge = itemsbuf[itemid].misc2;
11936 }
11937
11938 315641 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
11939
11940 315641 bool doCharge=true;
11941
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
315641 if(z!=0 && fakez != 0)
11942 doCharge=false;
11943
2/2
✓ Branch 0 taken 244921 times.
✓ Branch 1 taken 70720 times.
315641 if(attack==wSword)
11944 {
11945
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 244921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
244921 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
11946 244921 doCharge=false;
11947 else if(charging<=normalcharge)
11948 {
11949 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
11950 doCharge=false;
11951 }
11952 244921 }
11953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70720 times.
70720 else if(attack==wHammer)
11954 {
11955 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
11956 doCharge=false;
11957 else if(charging<=normalcharge)
11958 {
11959 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
11960 doCharge=false;
11961 }
11962 }
11963 else
11964 70720 doCharge=false;
11965
11966 // Now work out the magic cost
11967 315641 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
11968
11969 // charging up weapon...
11970 //
11971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
315641 if(doCharge)
11972 {
11973 // Increase charging while holding down button.
11974 if(spins==0 && charging<magiccharge)
11975 charging++;
11976
11977 // Once a charging threshold is reached, play the sound.
11978 if(charging==normalcharge)
11979 {
11980 paymagiccost(itemid); //!DIMITODO: Can this underflow or even just do it even if you don't have magic?
11981 sfx(WAV_ZN1CHARGE,pan(x.getInt()));
11982 }
11983 else if(charging==magiccharge)
11984 {
11985 itemid = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
11986
11987 if(itemid>-1 && checkbunny(itemid) && checkmagiccost(itemid))
11988 {
11989 paymagiccost(itemid);
11990 charging++; // charging>magiccharge signifies a successful supercharge.
11991 sfx(WAV_ZN1CHARGE2,pan(x.getInt()));
11992 }
11993 }
11994 }
11995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
315641 else if(attack==wCByrna && byrnaid!=-1)
11996 {
11997 if(!(itemsbuf[byrnaid].wpn))
11998 {
11999 attack = wNone;
12000 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12001 }
12002
12003 bool beamcount = false;
12004
12005 for(int32_t i=0; i<Lwpns.Count(); i++)
12006 {
12007 weapon *w = ((weapon*)Lwpns.spr(i));
12008
12009 if(w->id==wCByrna)
12010 {
12011 beamcount = true;
12012 break;
12013 }
12014 }
12015
12016 // If beams already deployed, remove them
12017 if(!attackclk && beamcount)
12018 {
12019 return startwpn(attackid); // Remove beams instantly
12020 }
12021
12022 // Otherwise, continue
12023 ++attackclk;
12024 }
12025 else
12026 {
12027 315641 ++attackclk;
12028
12029
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
315641 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12030 {
12031 ++attackclk; // Won't continue charging
12032 charging=0;
12033 }
12034
12035 // Faster if spinning.
12036
1/2
✓ Branch 0 taken 315641 times.
✗ Branch 1 not taken.
315641 if(spins>0)
12037 ++attackclk;
12038
12039 // Even faster if hurricane spinning.
12040
1/2
✓ Branch 0 taken 315641 times.
✗ Branch 1 not taken.
315641 if(spins>5)
12041 attackclk+=2;
12042
12043 // If at a charging threshold, do a charged attack.
12044
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
315641 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12045 {
12046 if(attack==wSword)
12047 {
12048 spins=(charging>magiccharge ? (itemsbuf[current_item_id(itype_spinscroll2)].misc1*4)-3
12049 : (itemsbuf[current_item_id(itype_spinscroll)].misc1*4)+1);
12050 attackclk=1;
12051 sfx(itemsbuf[current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
12052 }
12053 /*
12054 else if(attack==wWand)
12055 {
12056 //Not reachable.. yet
12057 spins=1;
12058 }
12059 */
12060 else if(attack==wHammer && sideviewhammerpound())
12061 {
12062 spins=1; //signifies the quake hammer
12063 bool super = (charging>magiccharge && current_item(itype_quakescroll2));
12064 sfx(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].usesound,pan(x.getInt()));
12065 quakeclk=(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc1);
12066
12067 // general area stun
12068 for(int32_t i=0; i<GuyCount(); i++)
12069 {
12070 if(!isflier(GuyID(i)))
12071 {
12072 StunGuy(i,(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc2)-
12073 distance(x,y,GuyX(i),GuyY(i)));
12074 }
12075 }
12076 }
12077 }
12078
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 315641 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
315641 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12079 charging++;
12080
12081
7/8
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 313204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 313204 times.
✓ Branch 4 taken 4326 times.
✓ Branch 5 taken 308878 times.
✓ Branch 6 taken 230962 times.
✓ Branch 7 taken 84679 times.
315641 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12082 84679 charging=0;
12083
12084
1/2
✓ Branch 0 taken 315641 times.
✗ Branch 1 not taken.
315641 if(attackclk>=SWORDCHARGEFRAME)
12085 tapping = false;
12086 }
12087
12088
6/8
✓ Branch 0 taken 24936 times.
✓ Branch 1 taken 290705 times.
✓ Branch 2 taken 201 times.
✓ Branch 3 taken 24735 times.
✓ Branch 4 taken 201 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 201 times.
315641 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12089 {
12090 201 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12091 }
12092
12093 315440 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12094
12095
5/12
✓ Branch 0 taken 295030 times.
✓ Branch 1 taken 20410 times.
✓ Branch 2 taken 22703 times.
✓ Branch 3 taken 272327 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22703 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
315440 if(attackclk==13 || (attackclk==7 && spins>1 && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12096 {
12097
12098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20410 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12099
2/2
✓ Branch 0 taken 20392 times.
✓ Branch 1 taken 18 times.
20410 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12100
12101
3/4
✓ Branch 0 taken 20392 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20392 times.
20410 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12102 {
12103 20392 templife=templife*game->get_maxlife();
12104 20392 templife=templife/100;
12105 20392 }
12106 else
12107 {
12108 18 templife*=game->get_hp_per_heart();
12109 }
12110
12111
2/2
✓ Branch 0 taken 8952 times.
✓ Branch 1 taken 11458 times.
20410 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12112 20410 int32_t perilid = current_item_id(itype_perilscroll);
12113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20410 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12114 && checkbunny(perilid) && checkmagiccost(perilid)
12115 // Must actually be able to shoot sword beams
12116 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12117 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12118
12119
3/4
✓ Branch 0 taken 17200 times.
✓ Branch 1 taken 3210 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17200 times.
20410 if(attack==wSword && !tapping)
12120 {
12121
3/4
✓ Branch 0 taken 17200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6156 times.
✓ Branch 3 taken 11044 times.
17200 if(perilbeam || normalbeam)
12122 {
12123
1/2
✓ Branch 0 taken 6156 times.
✗ Branch 1 not taken.
6156 if(attackclk==7)
12124 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12125
12126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6156 if(perilbeam && !normalbeam)
12127 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12128
12129 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12130 // a way to make the peril/cross beam item's power stat influence the strength
12131 // of the peril/cross beam...
12132 6156 startwpn(attackid);
12133 6156 }
12134 11044 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12135 17200 }
12136
12137
2/2
✓ Branch 0 taken 20101 times.
✓ Branch 1 taken 309 times.
20410 if(attack==wWand)
12138 309 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12139
12140
4/6
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 20257 times.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✗ Branch 5 not taken.
20410 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12141 startwpn(attackid);
12142
12143
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20410 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12144 startwpn(attackid);
12145 20410 }
12146
12147
2/2
✓ Branch 0 taken 295206 times.
✓ Branch 1 taken 20234 times.
315440 if(attackclk==14)
12148 20234 lstep = s;
12149
12150 315440 return true;
12151 339699 }
12152
12153 3800624 bool HeroClass::can_attack()
12154 {
12155
4/4
✓ Branch 0 taken 3770534 times.
✓ Branch 1 taken 30090 times.
✓ Branch 2 taken 2744102 times.
✓ Branch 3 taken 1026432 times.
3800624 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12156
4/6
✓ Branch 0 taken 3800624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3783606 times.
✓ Branch 3 taken 17018 times.
✓ Branch 4 taken 3783606 times.
✗ Branch 5 not taken.
4088692 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12157
4/8
✓ Branch 0 taken 3783606 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3783606 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3783606 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3783606 times.
✗ Branch 7 not taken.
3783606 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12158
3/4
✓ Branch 0 taken 3783606 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3133503 times.
✓ Branch 3 taken 650103 times.
3783606 || ((action==attacking||action==sideswimattacking)
12159
2/2
✓ Branch 0 taken 144034 times.
✓ Branch 1 taken 3639572 times.
3783606 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12160
2/2
✓ Branch 0 taken 3783606 times.
✓ Branch 1 taken 144034 times.
3783606 && charging!=0))
12161 {
12162 305086 return false;
12163 }
12164
12165 3783606 int32_t r = (isdungeon()) ? 16 : 0;
12166 3783606 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12167
12168
4/5
✓ Branch 0 taken 1111350 times.
✓ Branch 1 taken 2672256 times.
✓ Branch 2 taken 1135002 times.
✓ Branch 3 taken 1537254 times.
✗ Branch 4 not taken.
3783606 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12169 {
12170 case up:
12171 case down:
12172
2/2
✓ Branch 0 taken 1107718 times.
✓ Branch 1 taken 27284 times.
1135002 return !(y<(r2+r) || y>(160-r-r2));
12173
12174 case left:
12175 case right:
12176
2/2
✓ Branch 0 taken 1518726 times.
✓ Branch 1 taken 18528 times.
1537254 return !(x<(r2+r) || x>(240-r-r2));
12177 }
12178
12179 1111350 return true;
12180 4088692 }
12181
12182 869 bool isRaftFlag(int32_t flag)
12183 {
12184
4/4
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 460 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 391 times.
869 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12185 }
12186
12187 1907629 void handle_lens_triggers(int32_t l_id)
12188 {
12189
2/2
✓ Branch 0 taken 1907197 times.
✓ Branch 1 taken 432 times.
1907629 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12190
2/2
✓ Branch 0 taken 1907629 times.
✓ Branch 1 taken 13353403 times.
15261032 for(auto layer = 0; layer < 7; ++layer)
12191 {
12192 13353403 mapscr* tmp = FFCore.tempScreens[layer];
12193
2/2
✓ Branch 0 taken 2350198928 times.
✓ Branch 1 taken 13353403 times.
2363552331 for(auto pos = 0; pos < 176; ++pos)
12194 {
12195 2350198928 newcombo const& cmb = combobuf[tmp->data[pos]];
12196
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2350198928 times.
✓ Branch 2 taken 2350198928 times.
✗ Branch 3 not taken.
2350198928 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12197 2350198928 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12198 {
12199 do_trigger_combo(layer, pos);
12200 }
12201 2350198928 }
12202 13353403 }
12203
2/2
✓ Branch 0 taken 1898938 times.
✓ Branch 1 taken 8691 times.
1907629 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12204 {
12205 8691 word c = tmpscr->numFFC();
12206
2/2
✓ Branch 0 taken 8691 times.
✓ Branch 1 taken 127582 times.
136273 for(word i=0; i<c; i++)
12207 {
12208 127582 ffcdata& ffc = tmpscr->ffcs[i];
12209 127582 newcombo const& cmb = combobuf[ffc.getData()];
12210
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 127582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127582 times.
127582 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12211 127582 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12212 {
12213 do_trigger_combo_ffc(i);
12214 break;
12215 }
12216 127582 }
12217 8691 }
12218 1907629 }
12219
12220 1907629 void do_lens()
12221 {
12222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1907629 times.
1907629 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12223 {
12224 do_210_lens();
12225 return;
12226 }
12227
12228 1907629 int32_t wpnPressed = getWpnPressed(itype_lens);
12229
6/6
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1907197 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 1907171 times.
✓ Branch 4 taken 10124 times.
✓ Branch 5 taken 1897047 times.
1907629 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12230
2/2
✓ Branch 0 taken 1791986 times.
✓ Branch 1 taken 115643 times.
1907629 if(itemid >= 0)
12231 {
12232
7/10
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 115322 times.
✓ Branch 2 taken 321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 285 times.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 36 times.
115643 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12233 {
12234
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 26 times.
36 if(lensid<0)
12235 {
12236 26 lensid=itemid;
12237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(itemsbuf[itemid].family == itype_lens)
12238 26 Hero.setLastLensID(itemid);
12239
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12240 26 }
12241
12242 36 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12243
12244
2/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
36 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12245 {
12246 //clear the item script stack for a new script
12247 //itemScriptData[(itemid & 0xFFF)].Clear();
12248 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12249 ri = &(itemScriptData[itemid]);
12250 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12251 ri->Clear();
12252 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12253 item_doscript[itemid] = 1;
12254 itemscriptInitialised[itemid] = 0;
12255 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12256 did_scriptl=true;
12257 }
12258
12259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12260 36 else lensclk = 12;
12261 36 }
12262 else
12263 {
12264 115607 did_scriptl=false;
12265
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 115211 times.
115607 if(!lensclk)
12266 {
12267
12268
2/2
✓ Branch 0 taken 115185 times.
✓ Branch 1 taken 26 times.
115211 if(lensid>-1)
12269 {
12270 26 lensid=-1;
12271 26 lensclk = 0;
12272
12273
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12274 26 }
12275 115211 }
12276 }
12277 115643 }
12278 1907629 handle_lens_triggers(lensid);
12279 1907629 }
12280 //Add 2.10 version check to call this
12281 void do_210_lens()
12282 {
12283 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12284
12285 if(itemid<0)
12286 return;
12287
12288 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12289 {
12290 if(lensid<0)
12291 {
12292 lensid=itemid;
12293
12294 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12295 }
12296
12297 paymagiccost(itemid, true);
12298
12299 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12300 {
12301 //clear the item script stack for a new script
12302 //itemScriptData[(itemid & 0xFFF)].Clear();
12303 ri = &(itemScriptData[itemid]);
12304 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12305 ri->Clear();
12306 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12307 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12308 item_doscript[itemid] = 1;
12309 itemscriptInitialised[itemid] = 0;
12310 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12311 did_scriptl=true;
12312 }
12313
12314 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12315 else lensclk = 12;
12316 }
12317 else
12318 {
12319 did_scriptl=false;
12320
12321 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12322 {
12323 lensid=-1;
12324 lensclk = 0;
12325
12326 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12327 }
12328 }
12329 }
12330
12331 677 void HeroClass::do_hopping()
12332 {
12333 677 do_lens();
12334
12335
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 654 times.
677 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12336 //Possible fix for exiting water in diagonal movement. -Z
12337 {
12338 23 int32_t flippers_id = current_item_id(itype_flippers);
12339
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if(diveclk>0)
12340 {
12341 1 --diveclk;
12342
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12343 {
12344 diveclk = itemsbuf[flippers_id].misc2;
12345 }
12346 1 }
12347
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 else if(DrunkrAbtn())
12348 {
12349 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12350 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12351
12352 if(global_diving==screen_diving)
12353 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12354 }
12355
12356
2/6
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12357 {
12358 23 SetSwim();
12359 23 hopclk = 0;
12360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if (!IsSideSwim())
12361 {
12362 23 charging = attackclk = 0;
12363 23 tapping = false;
12364 23 }
12365 23 }
12366 else
12367 {
12368 herostep();
12369
12370 if(!isDiving() || (frame&1))
12371 {
12372 switch(dir)
12373 {
12374 case up:
12375 y -= 1;
12376 break;
12377
12378 case down:
12379 y += 1;
12380 break;
12381
12382 case left:
12383 x -= 1;
12384 break;
12385
12386 case right:
12387 x += 1;
12388 break;
12389 }
12390 }
12391 }
12392 23 }
12393 else // hopping in or out (need to separate the cases...)
12394 {
12395
2/4
✓ Branch 0 taken 654 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 654 times.
654 if((diagonalMovement||NO_GRIDLOCK))
12396 {
12397 if(hopclk==1) //hopping out
12398 //>= 1 possible fix for getting stuck on land edges.
12399 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12400 {
12401 if(hopdir!=-1) dir=hopdir;
12402
12403 landswim=0;
12404
12405 if(dir==up)
12406 {
12407 herostep();
12408 herostep();
12409 int32_t sidestep=0;
12410
12411 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12412 sidestep=1;
12413 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12414 sidestep=2;
12415
12416 if(sidestep==1) x++;
12417 else if(sidestep==2) x--;
12418 else y--;
12419
12420 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12421 {
12422 hopclk=0;
12423 diveclk=0;
12424 action=none; FFCore.setHeroAction(none);
12425 hopdir=-1;
12426 }
12427 }
12428
12429 if(dir==down)
12430 {
12431 herostep();
12432 herostep();
12433 int32_t sidestep=0;
12434
12435 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12436 sidestep=1;
12437 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12438 sidestep=2;
12439
12440 if(sidestep==1) x++;
12441 else if(sidestep==2) x--;
12442 else y++;
12443
12444 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12445 {
12446 hopclk=0;
12447 diveclk=0;
12448 action=none; FFCore.setHeroAction(none);
12449 hopdir=-1;
12450 }
12451 }
12452
12453 if(dir==left)
12454 {
12455 herostep();
12456 herostep();
12457 int32_t sidestep=0;
12458
12459 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12460 sidestep=1;
12461 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12462 sidestep=2;
12463
12464 if(sidestep==1) y++;
12465 else if(sidestep==2) y--;
12466 else x--;
12467
12468 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12469 {
12470 hopclk=0;
12471 diveclk=0;
12472 action=none; FFCore.setHeroAction(none);
12473 hopdir=-1;
12474 }
12475 }
12476
12477 if(dir==right)
12478 {
12479 herostep();
12480 herostep();
12481 int32_t sidestep=0;
12482
12483 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12484 sidestep=1;
12485 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12486 sidestep=2;
12487
12488 if(sidestep==1) y++;
12489 else if(sidestep==2) y--;
12490 else x++;
12491
12492 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12493 {
12494 hopclk=0;
12495 diveclk=0;
12496 action=none; FFCore.setHeroAction(none);
12497 hopdir=-1;
12498 }
12499 }
12500 }
12501
12502 if(hopclk==2) //hopping in
12503 {
12504 landswim=0;
12505
12506 if(dir==up)
12507 {
12508 herostep();
12509 herostep();
12510 int32_t sidestep=0;
12511
12512 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12513 sidestep=1;
12514 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12515 sidestep=2;
12516
12517 if(sidestep==1) x++;
12518 else if(sidestep==2) x--;
12519 else y--;
12520
12521 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12522 {
12523 hopclk=0xFF;
12524 diveclk=0;
12525 SetSwim();
12526 }
12527 }
12528
12529 if(dir==down)
12530 {
12531 herostep();
12532 herostep();
12533 int32_t sidestep=0;
12534
12535 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12536 sidestep=1;
12537 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12538 sidestep=2;
12539
12540 if(sidestep==1) x++;
12541 else if(sidestep==2) x--;
12542 else y++;
12543
12544 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12545 {
12546 hopclk=0xFF;
12547 diveclk=0;
12548 SetSwim();
12549 if (!IsSideSwim()) reset_swordcharge();
12550 }
12551 }
12552
12553 if(dir==left)
12554 {
12555 herostep();
12556 herostep();
12557 int32_t sidestep=0;
12558
12559 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12560 sidestep=1;
12561 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12562 sidestep=2;
12563
12564 if(sidestep==1) y++;
12565 else if(sidestep==2) y--;
12566 else x--;
12567
12568 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12569 {
12570 hopclk=0xFF;
12571 diveclk=0;
12572 SetSwim();
12573 }
12574 }
12575
12576 if(dir==right)
12577 {
12578 herostep();
12579 herostep();
12580
12581 int32_t sidestep=0;
12582
12583 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12584 sidestep=1;
12585 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12586 sidestep=2;
12587
12588 if(sidestep==1) y++;
12589 else if(sidestep==2) y--;
12590 else x++;
12591
12592 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12593 {
12594 hopclk=0xFF;
12595 diveclk=0;
12596 SetSwim();
12597 }
12598 }
12599 }
12600
12601 }
12602 else
12603 {
12604
7/8
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 408 times.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 189 times.
✓ Branch 5 taken 57 times.
✓ Branch 6 taken 34 times.
✓ Branch 7 taken 374 times.
654 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12605 {
12606 57 action=none; FFCore.setHeroAction(none);
12607 57 hopclk = 0;
12608 57 diveclk = 0;
12609
12610
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 29 times.
57 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12611 {
12612 // hopped in
12613 29 SetSwim();
12614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (!IsSideSwim()) attackclk = charging = spins = 0;
12615 29 }
12616 57 }
12617 else
12618 {
12619 597 herostep();
12620 597 herostep();
12621
12622
2/2
✓ Branch 0 taken 562 times.
✓ Branch 1 taken 35 times.
597 if(++hero_count>(16*hero_animation_speed))
12623 35 hero_count=0;
12624
12625 597 int32_t xofs2 = x.getInt()&15;
12626 597 int32_t yofs2 = y.getInt()&15;
12627 597 int32_t s = 1 + (frame&1);
12628
12629
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 198 times.
✓ Branch 4 taken 176 times.
597 switch(dir)
12630 {
12631 case up:
12632
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
25 if(yofs2<3 || yofs2>13) --y;
12633 16 else y-=s;
12634
12635 25 break;
12636
12637 case down:
12638
4/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 135 times.
198 if(yofs2<3 || yofs2>13) ++y;
12639 135 else y+=s;
12640
12641 198 break;
12642
12643 case left:
12644
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 141 times.
198 if(xofs2<3 || xofs2>13) --x;
12645 141 else x-=s;
12646
12647 198 break;
12648
12649 case right:
12650
4/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 120 times.
176 if(xofs2<3 || xofs2>13) ++x;
12651 120 else x+=s;
12652
12653 176 break;
12654 }
12655 }
12656 }
12657 }
12658 677 }
12659
12660 6640 void HeroClass::do_rafting()
12661 {
12662
12663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6640 times.
6640 if(toogam)
12664 {
12665 action=none; FFCore.setHeroAction(none);
12666 return;
12667 }
12668
12669 6640 FFCore.setHeroAction(rafting);
12670
12671 6640 do_lens();
12672
12673 6640 herostep();
12674
12675 //Calculate rafting speed
12676 6640 int32_t raft_item = current_item_id(itype_raft);
12677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6640 times.
6640 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12678 6640 raft_step = vbound(raft_step, -8, 5);
12679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6640 times.
6640 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6640 times.
6640 if(raft_step < 0) raft_step = 1;
12681 6640 int32_t step_inc = 1 << (raft_step - 1);
12682 // Fix position
12683
1/2
✓ Branch 0 taken 6640 times.
✗ Branch 1 not taken.
6640 if(raft_step > 1)
12684 {
12685 if(x.getInt() & (step_inc-1))
12686 {
12687 x = x.getInt() & ~(step_inc-1);
12688 }
12689 if(y.getInt() & (step_inc-1))
12690 {
12691 y = y.getInt() & ~(step_inc-1);
12692 }
12693 }
12694 // Inc clock, check if we need to move this frame
12695 6640 ++raftclk;
12696
2/4
✓ Branch 0 taken 6640 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6640 times.
6640 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12697
12698
4/4
✓ Branch 0 taken 3310 times.
✓ Branch 1 taken 3330 times.
✓ Branch 2 taken 2839 times.
✓ Branch 3 taken 471 times.
7106 if(!(x.getInt()&15) && !(y.getInt()&15))
12699 {
12700 // this sections handles switching to raft branches
12701
3/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
471 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12702 {
12703
5/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12704 {
12705 3 dir = up;
12706 3 goto skip;
12707 }
12708
12709
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12710 {
12711 dir = down;
12712 goto skip;
12713 }
12714
12715
5/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12716 {
12717 1 dir = left;
12718 1 goto skip;
12719 }
12720
12721
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12722 {
12723 1 dir = right;
12724 1 goto skip;
12725 }
12726 12 }
12727
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
454 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
12728 {
12729 if(dir == left) dir = right;
12730 else if(dir == right) dir = left;
12731 else if(dir == up) dir = down;
12732 else if(dir == down) dir = up;
12733 }
12734
12735
12736
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
466 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
12737 {
12738
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 23 times.
74 if(dir<left) //going up or down
12739 {
12740
3/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
51 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12741 3 dir=right;
12742
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
48 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12743 12 dir=left;
12744
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 7 times.
36 else if(y>0 && y<160)
12745 {
12746 22 action=none; FFCore.setHeroAction(none);
12747 22 x = x.getInt();
12748 22 y = y.getInt();
12749 22 }
12750 51 }
12751 else //going left or right
12752 {
12753
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
23 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12754 14 dir=down;
12755
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12756 2 dir=up;
12757
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 else if(x>0 && x<240)
12758 {
12759 7 action=none; FFCore.setHeroAction(none);
12760 7 x = x.getInt();
12761 7 y = y.getInt();
12762 7 }
12763 }
12764 74 }
12765 466 }
12766
12767 skip:
12768
12769
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1031 times.
✓ Branch 2 taken 2039 times.
✓ Branch 3 taken 1351 times.
✓ Branch 4 taken 2219 times.
6640 switch(dir)
12770 {
12771 case up:
12772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1031 times.
1031 if(x.getInt()&15)
12773 {
12774 if(x.getInt()&8)
12775 x++;
12776 else x--;
12777 }
12778 1031 else y -= step_inc;
12779
12780 1031 break;
12781
12782 case down:
12783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2039 times.
2039 if(x.getInt()&15)
12784 {
12785 if(x.getInt()&8)
12786 x++;
12787 else x--;
12788 }
12789 2039 else y += step_inc;
12790
12791 2039 break;
12792
12793 case left:
12794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1351 times.
1351 if(y.getInt()&15)
12795 {
12796 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12797 {
12798 if ((y.getInt() % 16) < 4) y--;
12799 else y++;
12800 }
12801 else
12802 {
12803 if(y.getInt()&8)
12804 y++;
12805 else y--;
12806 }
12807 }
12808 1351 else x -= step_inc;
12809
12810 1351 break;
12811
12812 case right:
12813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2219 times.
2219 if(y.getInt()&15)
12814 {
12815 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12816 {
12817 if ((y.getInt() % 16) <= 4) y--;
12818 else y++;
12819 }
12820 else
12821 {
12822 if(y.getInt()&8)
12823 y++;
12824 else y--;
12825 }
12826 }
12827 2219 else x += step_inc;
12828
12829 2219 break;
12830 }
12831 6640 }
12832
12833 bool HeroClass::try_hover()
12834 {
12835 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
12836 {
12837 int32_t itemid = current_item_id(itype_hoverboots);
12838 if(hoverclk < 0)
12839 hoverclk = -hoverclk;
12840 else
12841 {
12842 fall = fakefall = jumping = 0;
12843 if(itemsbuf[itemid].misc1)
12844 hoverclk = itemsbuf[itemid].misc1;
12845 else
12846 {
12847 hoverclk = 1;
12848 hoverflags |= HOV_INF;
12849 }
12850
12851
12852 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
12853 }
12854 if(itemsbuf[itemid].wpn)
12855 decorations.add(new dHover(x, y, dHOVER, 0));
12856 return true;
12857 }
12858 return false;
12859 }
12860
12861 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
12862 //Returns '-1' if not being pulled
12863 //Returns '-2' if should be falling in
12864 7550782 int32_t HeroClass::check_pitslide(bool ignore_hover)
12865 {
12866 //Pitfall todo -Emily
12867 //Iron boots; can't fight slipping, 2px/frame
12868 //Scripted variables to read pull dir/clk (clk only for non-hero)
12869 //Implement falling for all sprite types (npc AI)
12870 // Fall/slipping tiles for enemies
12871 // Fall/slipping SFX for enemies
12872 // Fall SFX for items/weapons
12873 // Weapons/Misc sprite shared for falling items/weapons
12874 //Maybe slip SFX for Hero?
12875 // Weapons/Misc sprite override for falling sprite?
12876 //Update std.zh with relevant new stuff
12877
2/2
✓ Branch 0 taken 188864 times.
✓ Branch 1 taken 7361918 times.
7550782 if(can_pitfall(ignore_hover))
12878 {
12879
2/2
✓ Branch 0 taken 18580 times.
✓ Branch 1 taken 7343338 times.
7361918 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
12880 7361918 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
12881 7361918 int32_t ispitbl = getpitfall(x,y+15);
12882 7361918 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
12883 7361918 int32_t ispitbr = getpitfall(x+15,y+15);
12884 7361918 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
12885 7361918 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
12886 7361918 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
12887 7361918 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
12888 7361918 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
12889 7361918 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
12890 7361918 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
12891 7361918 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
12892 static const int32_t flag_pit_irresistable = (1<<24);
12893
1/5
✓ Branch 0 taken 7361918 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
7361918 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
12894 {
12895 case 4: return -2; //Fully over pit; fall in
12896 case 3:
12897 {
12898 if(ispitul && ispitur && ispitbl) //UL_3
12899 {
12900 if(ispitul_50)
12901 {
12902 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
12903 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
12904 }
12905 }
12906 else if(ispitul && ispitur && ispitbr) //UR_3
12907 {
12908 if(ispitur_50)
12909 {
12910 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
12911 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
12912 }
12913 }
12914 else if(ispitul && ispitbl && ispitbr) //BL_3
12915 {
12916 if(ispitbl_50)
12917 {
12918 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
12919 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
12920 }
12921 }
12922 else if(ispitbl && ispitur && ispitbr) //BR_3
12923 {
12924 if(ispitbr_50)
12925 {
12926 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
12927 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
12928 }
12929 }
12930 break;
12931 }
12932 case 2:
12933 {
12934 if(ispitul && ispitur) //Up
12935 {
12936 if(DrunkDown())
12937 {
12938 if(ispitul_75 && ispitur_75) //Straight up
12939 {
12940 return up | flag_pit_irresistable | (ispitul << 8);
12941 }
12942 else if(ispitul_75)
12943 {
12944 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
12945 }
12946 else if(ispitur_75)
12947 {
12948 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
12949 }
12950 else return -1;
12951 }
12952 else
12953 {
12954 if(ispitul_50 && ispitur_50) //Straight up
12955 {
12956 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
12957 }
12958 else if(ispitul_50)
12959 {
12960 if(DrunkRight() && !ispitul_75) return -1;
12961 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
12962 }
12963 else if(ispitur_50)
12964 {
12965 if(DrunkLeft() && !ispitur_75) return -1;
12966 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
12967 }
12968 }
12969 }
12970 else if(ispitbl && ispitbr) //Down
12971 {
12972 if(DrunkUp())
12973 {
12974 if(ispitbl_75 && ispitbr_75) //Straight down
12975 {
12976 return down | flag_pit_irresistable | (ispitbl << 8);
12977 }
12978 else if(ispitbl_75)
12979 {
12980 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
12981 }
12982 else if(ispitbr_75)
12983 {
12984 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
12985 }
12986 else return -1;
12987 }
12988 else
12989 {
12990 if(ispitbl_50 && ispitbr_50) //Straight down
12991 {
12992 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
12993 }
12994 else if(ispitbl_50)
12995 {
12996 if(DrunkRight() && !ispitbl_75) return -1;
12997 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
12998 }
12999 else if(ispitbr_50)
13000 {
13001 if(DrunkLeft() && !ispitbr_75) return -1;
13002 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13003 }
13004 }
13005 }
13006 else if(ispitbl && ispitul) //Left
13007 {
13008 if(DrunkRight())
13009 {
13010 if(ispitul_75 && ispitbl_75) //Straight left
13011 {
13012 return left | flag_pit_irresistable | (ispitul << 8);
13013 }
13014 else if(ispitul_75)
13015 {
13016 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13017 }
13018 else if(ispitbl_75)
13019 {
13020 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13021 }
13022 else return -1;
13023 }
13024 else
13025 {
13026 if(ispitul_50 && ispitbl_50) //Straight left
13027 {
13028 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13029 }
13030 else if(ispitul_50)
13031 {
13032 if(DrunkDown() && !ispitul_75) return -1;
13033 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13034 }
13035 else if(ispitbl_50)
13036 {
13037 if(DrunkUp() && !ispitbl_75) return -1;
13038 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13039 }
13040 }
13041 }
13042 else if(ispitbr && ispitur) //Right
13043 {
13044 if(DrunkLeft())
13045 {
13046 if(ispitur_75 && ispitbr_75) //Straight right
13047 {
13048 return right | flag_pit_irresistable | (ispitur << 8);
13049 }
13050 else if(ispitur_75)
13051 {
13052 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13053 }
13054 else if(ispitbr_75)
13055 {
13056 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13057 }
13058 else return -1;
13059 }
13060 else
13061 {
13062 if(ispitur_50 && ispitbr_50) //Straight right
13063 {
13064 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13065 }
13066 else if(ispitur_50)
13067 {
13068 if(DrunkDown() && !ispitur_75) return -1;
13069 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13070 }
13071 else if(ispitbr_50)
13072 {
13073 if(DrunkUp() && !ispitbr_75) return -1;
13074 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13075 }
13076 }
13077 }
13078 break;
13079 }
13080 case 1:
13081 {
13082 if(ispitul && ispitul_50) //UL_1
13083 {
13084 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13085 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13086 }
13087 if(ispitur && ispitur_50) //UR_1
13088 {
13089 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13090 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13091 }
13092 if(ispitbl && ispitbl_50) //BL_1
13093 {
13094 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13095 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13096 }
13097 if(ispitbr && ispitbr_50) //BR_1
13098 {
13099 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13100 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13101 }
13102 break;
13103 }
13104 }
13105 7361918 }
13106 7550782 return -1;
13107 7550782 }
13108
13109 1585241 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13110 {
13111 1585241 pitfall();
13112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585241 times.
1585241 if(fallclk) return true;
13113 1585241 int32_t val = check_pitslide();
13114 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585241 times.
1585241 if(val == -1)
13116 {
13117 1585241 pit_pulldir = -1;
13118 1585241 pit_pullclk = 0;
13119 1585241 return false;
13120 }
13121 int32_t dir = val&0xFF;
13122 int32_t cmbid = (val&0xFFFF00)>>8;
13123 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13124 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13125 {
13126 pit_pulldir = -1;
13127 pit_pullclk = 0;
13128 return false;
13129 }
13130 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13131 {
13132 pit_pulldir = -1;
13133 pit_pullclk = 0;
13134 return false;
13135 }
13136 pit_pulldir = dir;
13137 int32_t step = 1;
13138 if(sensitivity == 0)
13139 {
13140 step = 2;
13141 sensitivity = 1;
13142 }
13143 if(pit_pullclk++ % sensitivity) //No pull this frame
13144 return (val&0x100);
13145 for(; step > 0 && !fallclk; --step)
13146 {
13147 switch(dir)
13148 {
13149 case l_up: case l_down: case left:
13150 --x; break;
13151 case r_up: case r_down: case right:
13152 ++x; break;
13153 }
13154 switch(dir)
13155 {
13156 case l_up: case r_up: case up:
13157 --y; break;
13158 case l_down: case r_down: case down:
13159 ++y; break;
13160 }
13161 pitfall();
13162 }
13163 return fallclk || (val&0x100);
13164 1585241 }
13165
13166 1585241 void HeroClass::pitfall()
13167 {
13168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585241 times.
1585241 if(fallclk)
13169 {
13170 drop_liftwpn();
13171 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13172 //Handle falling
13173 if(!--fallclk)
13174 {
13175 int32_t dmg = game->get_hp_per_heart()/4;
13176 bool dmg_perc = false;
13177 bool warp = false;
13178
13179 action=none; FFCore.setHeroAction(none);
13180 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13181 if(cmb)
13182 {
13183 dmg = cmb->attributes[0]/10000L;
13184 dmg_perc = cmb->usrflags&cflag3;
13185 warp = cmb->usrflags&cflag1;
13186 }
13187 if(dmg) //Damage
13188 {
13189 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13190 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13191 }
13192 if(warp) //Warp
13193 {
13194 sdir = dir;
13195 if(cmb->usrflags&cflag2) //Direct Warp
13196 {
13197 didpit=true;
13198 pitx=x;
13199 pity=y;
13200 }
13201 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13202 }
13203 else //Reset to screen entry
13204 {
13205 go_respawn_point();
13206 }
13207 }
13208 }
13209
2/2
✓ Branch 0 taken 34742 times.
✓ Branch 1 taken 1550499 times.
1585241 else if(can_pitfall())
13210 {
13211 1550499 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13212 1550499 bool ispitbl = ispitfall(x,y+15);
13213 1550499 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13214 1550499 bool ispitbr = ispitfall(x+15,y+15);
13215 1550499 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13216
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1550499 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1550499 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13217 {
13218 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13219 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13220 fallclk = PITFALL_FALL_FRAMES;
13221 fallCombo = pitctr;
13222 action=falling; FFCore.setHeroAction(falling);
13223 spins = 0;
13224 charging = 0;
13225 drop_liftwpn();
13226 }
13227 1550499 }
13228 1585241 }
13229
13230 1906923 void HeroClass::movehero()
13231 {
13232
2/4
✓ Branch 0 taken 1906923 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1906923 times.
1906923 if(lstunclock || is_conveyor_stunned) return;
13233 1906923 int32_t xoff=x.getInt()&7;
13234 1906923 int32_t yoff=y.getInt()&7;
13235
2/2
✓ Branch 0 taken 1897613 times.
✓ Branch 1 taken 9310 times.
1906923 if(NO_GRIDLOCK)
13236 {
13237 9310 xoff = 0;
13238 9310 yoff = 0;
13239 9310 }
13240 1906923 int32_t push=pushing;
13241 1906923 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13242 1906923 pushing=0;
13243 1906923 zfix temp_step(hero_newstep);
13244 1906923 zfix temp_x(x);
13245 1906923 zfix temp_y(y);
13246
13247 1906923 int32_t flippers_id = current_item_id(itype_flippers);
13248
2/2
✓ Branch 0 taken 2137 times.
✓ Branch 1 taken 1904786 times.
1906923 if(diveclk>0)
13249 {
13250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2137 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2137 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13251 2137 --diveclk;
13252
4/8
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 741 times.
✓ Branch 2 taken 1396 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1396 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2137 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
13253 {
13254 diveclk = itemsbuf[flippers_id].misc2;
13255 }
13256 2137 }
13257
4/4
✓ Branch 0 taken 6372 times.
✓ Branch 1 taken 1898414 times.
✓ Branch 2 taken 6341 times.
✓ Branch 3 taken 31 times.
1904786 else if(action == swimming && DrunkrAbtn())
13258 {
13259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13260 31 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13261
13262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(global_diving==screen_diving)
13263
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13264 31 }
13265
13266
2/2
✓ Branch 0 taken 1900283 times.
✓ Branch 1 taken 6640 times.
1906923 if(action==rafting)
13267 {
13268 6640 do_rafting();
13269
13270
2/2
✓ Branch 0 taken 6611 times.
✓ Branch 1 taken 29 times.
6640 if(action==rafting)
13271 {
13272 6611 return;
13273 }
13274
13275
13276 29 set_respawn_point();
13277 29 trySideviewLadder();
13278 29 }
13279
13280 1900312 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13281 1900312 int32_t btnwpn = -1;
13282
13283 //&0xFFF removes the "bow & arrows" bitmask
13284 //The Quick Sword is allowed to interrupt attacks.
13285
4/4
✓ Branch 0 taken 1885267 times.
✓ Branch 1 taken 15045 times.
✓ Branch 2 taken 1372054 times.
✓ Branch 3 taken 513213 times.
1900312 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13286
7/8
✓ Branch 0 taken 1586176 times.
✓ Branch 1 taken 314136 times.
✓ Branch 2 taken 1583969 times.
✓ Branch 3 taken 2207 times.
✓ Branch 4 taken 72277 times.
✓ Branch 5 taken 244066 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 316343 times.
1900312 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13287 {
13288
2/2
✓ Branch 0 taken 5016 times.
✓ Branch 1 taken 1578953 times.
1583969 if(DrunkrBbtn())
13289 {
13290 5016 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13291 5016 dowpn = Bwpn&0xFFF;
13292 5016 directWpn = directItemB;
13293 5016 }
13294
2/2
✓ Branch 0 taken 18193 times.
✓ Branch 1 taken 1560760 times.
1578953 else if(DrunkrAbtn())
13295 {
13296 18193 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13297 18193 dowpn = Awpn&0xFFF;
13298 18193 directWpn = directItemA;
13299 18193 }
13300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1560760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1560760 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13301 {
13302 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13303 dowpn = Xwpn&0xFFF;
13304 directWpn = directItemX;
13305 }
13306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1560760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1560760 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13307 {
13308 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13309 dowpn = Ywpn&0xFFF;
13310 directWpn = directItemY;
13311 }
13312
13313
1/2
✓ Branch 0 taken 1583969 times.
✗ Branch 1 not taken.
1583969 if(directWpn > 255) directWpn = 0;
13314
13315 // The Quick Sword only allows repeated sword or wand swings.
13316
3/8
✓ Branch 0 taken 1583969 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1583969 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1583969 times.
1583969 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13317 btnwpn=-1;
13318 1583969 }
13319
13320
1/2
✓ Branch 0 taken 1900312 times.
✗ Branch 1 not taken.
1900312 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13321
10/12
✓ Branch 0 taken 1848920 times.
✓ Branch 1 taken 51392 times.
✓ Branch 2 taken 1828307 times.
✓ Branch 3 taken 20613 times.
✓ Branch 4 taken 1828307 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1802393 times.
✓ Branch 7 taken 25914 times.
✓ Branch 8 taken 17965 times.
✓ Branch 9 taken 1784428 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 17965 times.
1900312 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13322 {
13323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17965 times.
17965 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13324
2/6
✓ Branch 0 taken 17965 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17965 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17965 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13325 {
13326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17965 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17965 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13327 {
13328 paymagiccost(attackid,true);
13329 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13330 }
13331 17965 SetAttack();
13332 17965 attack=wSword;
13333
13334 17965 attackclk=0;
13335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17965 times.
17965 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13336
13337
2/10
✓ Branch 0 taken 17965 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17965 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
17965 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13338 {
13339 if(!checkmagiccost(dowpn))
13340 {
13341 if(QMisc.miscsfx[sfxERROR])
13342 sfx(QMisc.miscsfx[sfxERROR]);
13343 }
13344 else
13345 {
13346 //clear the item script stack for a new script
13347
13348 ri = &(itemScriptData[dowpn]);
13349 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13350 ri->Clear();
13351 //itemScriptData[(dowpn & 0xFFF)].Clear();
13352 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13353 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13354 item_doscript[dowpn] = 1;
13355 itemscriptInitialised[dowpn] = 0;
13356 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13357 did_scripta=true;
13358 }
13359 }
13360 17965 }
13361 else
13362 {
13363 if(QMisc.miscsfx[sfxERROR])
13364 sfx(QMisc.miscsfx[sfxERROR]);
13365 }
13366 17965 }
13367 else
13368 {
13369 1882347 did_scripta=false;
13370 }
13371
13372
7/10
✓ Branch 0 taken 1891803 times.
✓ Branch 1 taken 8509 times.
✓ Branch 2 taken 1891803 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1891803 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1891803 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 304 times.
✓ Branch 9 taken 1891499 times.
1900312 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13373 {
13374
4/4
✓ Branch 0 taken 327124 times.
✓ Branch 1 taken 1564375 times.
✓ Branch 2 taken 327122 times.
✓ Branch 3 taken 2 times.
1891499 if(DrunkUp() && canSideviewLadder())
13375 {
13376 2 setOnSideviewLadder(true);
13377 2 }
13378
4/4
✓ Branch 0 taken 260033 times.
✓ Branch 1 taken 1631464 times.
✓ Branch 2 taken 260028 times.
✓ Branch 3 taken 5 times.
1891497 else if(DrunkDown() && canSideviewLadder(true))
13379 {
13380 5 y+=1;
13381 5 setOnSideviewLadder(true);
13382 5 }
13383 1891499 }
13384
13385 1900312 int32_t wx=x;
13386 1900312 int32_t wy=y;
13387
5/6
✓ Branch 0 taken 1443220 times.
✓ Branch 1 taken 457092 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 1900001 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 311 times.
1900312 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13388 {
13389
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
311 if((xoff==0)||diagonalMovement)
13390 {
13391
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 109 times.
311 if(DrunkUp()) dir=up;
13392
2/2
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 160 times.
311 if(DrunkDown()) dir=down;
13393 311 }
13394
13395
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
311 if((yoff==0)||diagonalMovement)
13396 {
13397
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 43 times.
311 if(DrunkLeft()) dir=left;
13398
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 6 times.
311 if(DrunkRight()) dir=right;
13399 311 }
13400 311 }
13401
13402
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 454204 times.
✓ Branch 2 taken 376877 times.
✓ Branch 3 taken 521489 times.
✓ Branch 4 taken 547742 times.
1900312 switch(dir)
13403 {
13404 case up:
13405 454204 wy-=16;
13406 454204 break;
13407
13408 case down:
13409 376877 wy+=16;
13410 376877 break;
13411
13412 case left:
13413 521489 wx-=16;
13414 521489 break;
13415
13416 case right:
13417 547742 wx+=16;
13418 547742 break;
13419 }
13420
13421 1900312 do_lens();
13422
13423 1900312 WalkflagInfo info;
13424
13425 1900312 bool no_jinx = true;
13426
7/8
✓ Branch 0 taken 1848920 times.
✓ Branch 1 taken 51392 times.
✓ Branch 2 taken 5003 times.
✓ Branch 3 taken 1843917 times.
✓ Branch 4 taken 5003 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 4987 times.
1900312 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13427 {
13428 4987 bool paidmagic = false;
13429
4/8
✓ Branch 0 taken 4678 times.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 309 times.
4987 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13430 {
13431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
309 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13432 309 no_jinx = checkitem_jinx(attackid);
13433
3/8
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 309 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
309 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13434 {
13435
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
309 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13436 paymagiccost(attackid,true);
13437 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13438 }
13439 309 SetAttack();
13440 309 attack=wWand;
13441 309 attackclk=0;
13442 309 }
13443 else
13444 {
13445 if(QMisc.miscsfx[sfxERROR])
13446 sfx(QMisc.miscsfx[sfxERROR]);
13447 }
13448 309 }
13449
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4678 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13450 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13451 {
13452 no_jinx = checkitem_jinx(dowpn);
13453 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13454 {
13455 if(QMisc.miscsfx[sfxERROR])
13456 sfx(QMisc.miscsfx[sfxERROR]);
13457 }
13458 else
13459 {
13460 paymagiccost(dowpn);
13461 paidmagic = true;
13462 SetAttack();
13463 attack=wHammer;
13464 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13465 attackclk=0;
13466 }
13467 }
13468
4/6
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 4477 times.
✓ Branch 2 taken 201 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 201 times.
4879 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13469
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 201 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
201 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13470 {
13471 //checkbunny handled where magic cost is paid
13472
1/2
✓ Branch 0 taken 201 times.
✗ Branch 1 not taken.
201 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13473 201 no_jinx = checkitem_jinx(attackid);
13474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
201 if(no_jinx)
13475 {
13476 201 SetAttack();
13477 201 attack=wFire;
13478 201 attackclk=0;
13479 201 }
13480 201 }
13481
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4477 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4477 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13482 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13483 {
13484 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13485 no_jinx = checkitem_jinx(attackid);
13486 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13487 {
13488 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13489 paymagiccost(attackid,true);
13490 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13491 }
13492 SetAttack();
13493 attack=wCByrna;
13494 attackclk=0;
13495 }
13496 else
13497 {
13498 if(QMisc.miscsfx[sfxERROR])
13499 sfx(QMisc.miscsfx[sfxERROR]);
13500 }
13501 }
13502
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4477 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4477 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13503 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13504 {
13505 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13506 no_jinx = checkitem_jinx(attackid);
13507 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13508 {
13509 paymagiccost(attackid);
13510 SetAttack();
13511 attack = wBugNet;
13512 attackclk = 0;
13513 sfx(itemsbuf[attackid].usesound);
13514 }
13515 else
13516 {
13517 if(QMisc.miscsfx[sfxERROR])
13518 sfx(QMisc.miscsfx[sfxERROR]);
13519 }
13520 }
13521 else
13522 {
13523
1/2
✓ Branch 0 taken 4477 times.
✗ Branch 1 not taken.
4477 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13524 4477 no_jinx = checkitem_jinx(itmid);
13525
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4474 times.
4477 if(no_jinx)
13526 {
13527 4474 paidmagic = startwpn(itmid);
13528
13529
2/2
✓ Branch 0 taken 4254 times.
✓ Branch 1 taken 220 times.
4474 if(paidmagic)
13530 {
13531
5/10
✓ Branch 0 taken 4254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4254 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4254 times.
4254 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13532 {
13533 ;
13534 }
13535 else
13536 {
13537 4254 SetAttack();
13538 4254 attackclk=0;
13539 4254 attack=none;
13540
13541
2/2
✓ Branch 0 taken 542 times.
✓ Branch 1 taken 3712 times.
4254 if(btnwpn==itype_brang)
13542 {
13543 3712 attack=wBrang;
13544 3712 }
13545 }
13546 4254 }
13547 else
13548 {
13549 // Weapon not started: directWpn should be reset to prev. value.
13550 220 directWpn = olddirectwpn;
13551 }
13552 4474 }
13553 }
13554
13555
4/12
✓ Branch 0 taken 4987 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4984 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4984 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4987 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13556 {
13557 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13558 {
13559 if(QMisc.miscsfx[sfxERROR])
13560 sfx(QMisc.miscsfx[sfxERROR]);
13561 }
13562 else
13563 {
13564 // Only charge for magic if item's magic cost wasn't already charged
13565 // for the item's main use.
13566 if(!paidmagic && attack!=wWand)
13567 paymagiccost(dowpn);
13568 //clear the item script stack for a new script
13569 //itemScriptData[(dowpn & 0xFFF)].Clear();
13570 ri = &(itemScriptData[dowpn]);
13571 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13572 ri->Clear();
13573 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13574 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13575 item_doscript[dowpn] = 1;
13576 itemscriptInitialised[dowpn] = 0;
13577 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13578 did_scriptb=true;
13579 }
13580 }
13581
13582
7/12
✓ Branch 0 taken 4984 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 4984 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4984 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4984 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4984 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4984 times.
4987 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13583 {
13584 return;
13585 }
13586
2/2
✓ Branch 0 taken 4984 times.
✓ Branch 1 taken 3 times.
4987 if(!no_jinx)
13587 3 did_scriptb = false;
13588 4987 }
13589 else
13590 {
13591 1895325 did_scriptb=false;
13592 }
13593
13594
5/6
✓ Branch 0 taken 1586176 times.
✓ Branch 1 taken 314136 times.
✓ Branch 2 taken 1561240 times.
✓ Branch 3 taken 24936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1561240 times.
1900312 if(attackclk || action==attacking || action==sideswimattacking)
13595 {
13596
13597
4/8
✓ Branch 0 taken 24936 times.
✓ Branch 1 taken 314136 times.
✓ Branch 2 taken 24936 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24936 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
339072 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13598 {
13599 if((xoff==0)||diagonalMovement)
13600 {
13601 if(DrunkUp()) dir=up;
13602 if(DrunkDown()) dir=down;
13603 }
13604
13605 if((yoff==0)||diagonalMovement)
13606 {
13607 if(DrunkLeft()) dir=left;
13608 if(DrunkRight()) dir=right;
13609 }
13610 }
13611
13612 339072 bool attacked = doattack();
13613
13614 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
13615
9/12
✓ Branch 0 taken 338985 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 239974 times.
✓ Branch 3 taken 99011 times.
✓ Branch 4 taken 44730 times.
✓ Branch 5 taken 195244 times.
✓ Branch 6 taken 44730 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 44730 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 44730 times.
339072 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
13616 {
13617
3/4
✓ Branch 0 taken 19527 times.
✓ Branch 1 taken 25203 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19527 times.
44730 if((xoff==0)||diagonalMovement)
13618 {
13619
2/2
✓ Branch 0 taken 23173 times.
✓ Branch 1 taken 2030 times.
25203 if(DrunkUp()) dir=up;
13620
13621
2/2
✓ Branch 0 taken 23048 times.
✓ Branch 1 taken 2155 times.
25203 if(DrunkDown()) dir=down;
13622 25203 }
13623
13624
3/4
✓ Branch 0 taken 13392 times.
✓ Branch 1 taken 31338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13392 times.
44730 if((yoff==0)||diagonalMovement)
13625 {
13626
2/2
✓ Branch 0 taken 28424 times.
✓ Branch 1 taken 2914 times.
31338 if(DrunkLeft()) dir=left;
13627
13628
2/2
✓ Branch 0 taken 28490 times.
✓ Branch 1 taken 2848 times.
31338 if(DrunkRight()) dir=right;
13629 31338 }
13630 44730 }
13631
13632
6/10
✓ Branch 0 taken 315071 times.
✓ Branch 1 taken 24001 times.
✓ Branch 2 taken 315071 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 315071 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315071 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 315071 times.
339072 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
13633 {
13634 315071 return;
13635 }
13636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24001 times.
24001 else if(!(attacked))
13637 {
13638 // Spin attack - change direction
13639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24001 times.
24001 if(spins>1)
13640 {
13641 spins--;
13642
13643 if(spins%5==0)
13644 sfx(itemsbuf[current_item_id(spins >5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
13645
13646 attackclk=1;
13647
13648 switch(dir)
13649 {
13650 case up:
13651 dir=left;
13652 break;
13653
13654 case right:
13655 dir=up;
13656 break;
13657
13658 case down:
13659 dir=right;
13660 break;
13661
13662 case left:
13663 dir=down;
13664 break;
13665 }
13666
13667 return;
13668 }
13669 else
13670 {
13671 24001 spins=0;
13672 }
13673
13674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24001 times.
24001 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
13675 24001 else {action=none; FFCore.setHeroAction(none);}
13676 24001 attackclk=0;
13677 24001 charging=0;
13678 24001 }
13679 24001 }
13680
13681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585241 times.
1585241 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
13682 return;
13683
13684
2/2
✓ Branch 0 taken 487839 times.
✓ Branch 1 taken 1097402 times.
1585241 if(action==walking) //still walking
13685 {
13686
9/10
✓ Branch 0 taken 823467 times.
✓ Branch 1 taken 273935 times.
✓ Branch 2 taken 616363 times.
✓ Branch 3 taken 207104 times.
✓ Branch 4 taken 324375 times.
✓ Branch 5 taken 291988 times.
✓ Branch 6 taken 12373 times.
✓ Branch 7 taken 312002 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 12373 times.
1097402 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
13687 {
13688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12373 times.
12373 if(attackclk>0) SetAttack();
13689 12373 else {action = none; FFCore.setHeroAction(none);}
13690 12373 hero_count=-1;
13691 12373 return;
13692 }
13693
13694 1085029 autostep=false;
13695
13696
3/4
✓ Branch 0 taken 1079925 times.
✓ Branch 1 taken 5104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1079925 times.
1085029 if(!(diagonalMovement || NO_GRIDLOCK))
13697 {
13698
2/4
✓ Branch 0 taken 1079925 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1079925 times.
1079925 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
13699 {
13700 if(dir==up&&yoff)
13701 {
13702 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
13703 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
13704 execute(info);
13705
13706 if(!info.isUnwalkable())
13707 {
13708 move(up);
13709 }
13710 else
13711 {
13712 action=none; FFCore.setHeroAction(none);
13713 }
13714
13715 return;
13716 }
13717
13718 if(dir==down&&yoff)
13719 {
13720 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
13721 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
13722 execute(info);
13723
13724 if(!info.isUnwalkable())
13725 {
13726 move(down);
13727 }
13728 else
13729 {
13730 action=none; FFCore.setHeroAction(none);
13731 }
13732
13733 return;
13734 }
13735
13736 if(dir==left&&xoff)
13737 {
13738 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
13739 execute(info);
13740
13741 if(!info.isUnwalkable())
13742 {
13743 move(left);
13744 }
13745 else
13746 {
13747 action=none; FFCore.setHeroAction(none);
13748 }
13749
13750 return;
13751 }
13752
13753 if(dir==right&&xoff)
13754 {
13755 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
13756 execute(info);
13757
13758 if(!info.isUnwalkable())
13759 {
13760 move(right);
13761 }
13762 else
13763 {
13764 action=none; FFCore.setHeroAction(none);
13765 }
13766
13767 return;
13768 }
13769 }
13770 else
13771 {
13772
4/4
✓ Branch 0 taken 260595 times.
✓ Branch 1 taken 819330 times.
✓ Branch 2 taken 42789 times.
✓ Branch 3 taken 217806 times.
1079925 if(dir==up&&yoff)
13773 {
13774 217806 while(true)
13775 {
13776 217806 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
13777 217806 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
13778 217806 execute(info);
13779
13780
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 217297 times.
217806 if(!info.isUnwalkable())
13781 {
13782 217297 hero_newstep = temp_step;
13783 217297 x = temp_x;
13784 217297 y = temp_y;
13785 217297 move(up);
13786 217297 return;
13787 }
13788 //Could not move, try moving less
13789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 509 times.
509 if(temp_y != int32_t(temp_y))
13790 {
13791 temp_y = floor((double)temp_y);
13792 continue;
13793 }
13794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 509 times.
509 else if(temp_step > 1)
13795 {
13796 if(temp_step != int32_t(temp_step)) //floor
13797 temp_step = floor((double)temp_step);
13798 else --temp_step;
13799 continue;
13800 }
13801 else //Can't move less, stop moving
13802 {
13803 509 action=none; FFCore.setHeroAction(none);
13804 }
13805 509 return;
13806 }
13807 }
13808
13809
4/4
✓ Branch 0 taken 200129 times.
✓ Branch 1 taken 661990 times.
✓ Branch 2 taken 33162 times.
✓ Branch 3 taken 166967 times.
862119 if(dir==down&&yoff)
13810 {
13811 166967 while(true)
13812 {
13813 166970 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
13814 166970 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
13815 166970 execute(info);
13816
13817
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 166503 times.
166970 if(!info.isUnwalkable())
13818 {
13819 166503 hero_newstep = temp_step;
13820 166503 x = temp_x;
13821 166503 y = temp_y;
13822 166503 move(down);
13823 166503 return;
13824 }
13825 //Could not move, try moving less
13826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(temp_y != int32_t(temp_y))
13827 {
13828 temp_y = floor((double)temp_y);
13829 continue;
13830 }
13831
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 464 times.
467 else if(temp_step > 1)
13832 {
13833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(temp_step != int32_t(temp_step)) //floor
13834 3 temp_step = floor((double)temp_step);
13835 else --temp_step;
13836 3 continue;
13837 }
13838 else //Can't move less, stop moving
13839 {
13840 464 action=none; FFCore.setHeroAction(none);
13841 }
13842 464 return;
13843 }
13844 }
13845
13846
4/4
✓ Branch 0 taken 300060 times.
✓ Branch 1 taken 395092 times.
✓ Branch 2 taken 50504 times.
✓ Branch 3 taken 249556 times.
695152 if(dir==left&&xoff)
13847 {
13848 249556 while(true)
13849 {
13850 249556 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
13851 249556 execute(info);
13852
13853
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 249287 times.
249556 if(!info.isUnwalkable())
13854 {
13855 249287 hero_newstep = temp_step;
13856 249287 x = temp_x;
13857 249287 y = temp_y;
13858 249287 move(left);
13859 249287 return;
13860 }
13861 //Could not move, try moving less
13862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
269 if(temp_x != int32_t(temp_x))
13863 {
13864 temp_x = floor((double)temp_x);
13865 continue;
13866 }
13867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
269 else if(temp_step > 1)
13868 {
13869 if(temp_step != int32_t(temp_step)) //floor
13870 temp_step = floor((double)temp_step);
13871 else --temp_step;
13872 continue;
13873 }
13874 else //Can't move less, stop moving
13875 {
13876 269 action=none; FFCore.setHeroAction(none);
13877 }
13878 269 return;
13879 }
13880 }
13881
13882
4/4
✓ Branch 0 taken 319141 times.
✓ Branch 1 taken 126455 times.
✓ Branch 2 taken 53511 times.
✓ Branch 3 taken 265630 times.
445596 if(dir==right&&xoff)
13883 {
13884 265630 while(true)
13885 {
13886 265636 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
13887 265636 execute(info);
13888
13889
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 265339 times.
265636 if(!info.isUnwalkable())
13890 {
13891 265339 hero_newstep = temp_step;
13892 265339 x = temp_x;
13893 265339 y = temp_y;
13894 265339 move(right);
13895 265339 return;
13896 }
13897 //Could not move, try moving less
13898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(temp_x != int32_t(temp_x))
13899 {
13900 temp_x = floor((double)temp_x);
13901 continue;
13902 }
13903
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 291 times.
297 else if(temp_step > 1)
13904 {
13905
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
13906 6 temp_step = floor((double)temp_step);
13907 else --temp_step;
13908 6 continue;
13909 }
13910 else //Can't move less, stop moving
13911 {
13912 291 action=none; FFCore.setHeroAction(none);
13913 }
13914 291 return;
13915 }
13916 }
13917 }
13918 179966 }
13919
13920 185070 } // endif (action==walking)
13921
13922
14/24
✓ Branch 0 taken 664400 times.
✓ Branch 1 taken 8509 times.
✓ Branch 2 taken 664400 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 664400 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 664400 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 664400 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 664400 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 664400 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 664400 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 664400 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 664400 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 664400 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1430 times.
✓ Branch 23 taken 662970 times.
672909 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
13923 {
13924 662970 action=none; FFCore.setHeroAction(none);
13925 662970 }
13926
13927
2/2
✓ Branch 0 taken 9237 times.
✓ Branch 1 taken 663672 times.
672909 if(diagonalMovement)
13928 {
13929
5/5
✓ Branch 0 taken 2505 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 757 times.
✓ Branch 3 taken 2183 times.
✓ Branch 4 taken 3118 times.
9237 switch(holddir)
13930 {
13931 case up:
13932
2/2
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 24 times.
674 if(!Up())
13933 {
13934 24 holddir=-1;
13935 24 }
13936
13937 674 break;
13938
13939 case down:
13940
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 26 times.
757 if(!Down())
13941 {
13942 26 holddir=-1;
13943 26 }
13944
13945 757 break;
13946
13947 case left:
13948
2/2
✓ Branch 0 taken 2123 times.
✓ Branch 1 taken 60 times.
2183 if(!Left())
13949 {
13950 60 holddir=-1;
13951 60 }
13952
13953 2183 break;
13954
13955 case right:
13956
2/2
✓ Branch 0 taken 3042 times.
✓ Branch 1 taken 76 times.
3118 if(!Right())
13957 {
13958 76 holddir=-1;
13959 76 }
13960
13961 3118 break;
13962
13963 default:
13964 2505 break;
13965 } //end switch
13966
13967
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9237 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9237 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
13968 {
13969 9237 walkable = false;
13970
6/6
✓ Branch 0 taken 989 times.
✓ Branch 1 taken 8248 times.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 650 times.
9237 if(DrunkUp()&&(holddir==-1||holddir==up))
13971 {
13972
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
674 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
13973 {
13974 }
13975 else
13976 {
13977
4/10
✓ Branch 0 taken 674 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 674 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 674 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 674 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
674 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
13978 {
13979 674 dir=up;
13980 674 }
13981
13982 674 holddir=up;
13983
13984
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 578 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
674 if(DrunkRight()&&shiftdir!=left)
13985 {
13986 96 shiftdir=right;
13987
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
96 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
13988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
96 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
13989 96 }
13990
3/4
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 228 times.
578 else if(DrunkLeft()&&shiftdir!=right)
13991 {
13992 228 shiftdir=left;
13993
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
13994
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
228 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
13995 228 }
13996 else
13997 {
13998 350 shiftdir=-1;
13999 }
14000
14001 //walkable if Ladder can be placed or is already placed vertically
14002
9/20
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 297 times.
✓ Branch 2 taken 377 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 272 times.
✓ Branch 13 taken 105 times.
✓ Branch 14 taken 272 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 272 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 272 times.
674 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14003 {
14004 272 walkable=false;
14005 272 }
14006 else
14007 {
14008 402 do
14009 {
14010 469 info = walkflag(x,(bigHitbox?0:8)+(y-hero_newstep),2,up);
14011
14012 469 info = info || walkflag(x+15,(bigHitbox?0:8)+(y-hero_newstep),1,up);
14013 469 info = info || walkflagMBlock(x+15, (bigHitbox?0:8)+(y-hero_newstep));
14014
14015 469 execute(info);
14016
14017
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 339 times.
469 if(info.isUnwalkable())
14018 {
14019
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(y != y.getInt())
14020 {
14021 4 y.doRound();
14022 4 }
14023
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 else if(hero_newstep > 1)
14024 {
14025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(hero_newstep != int32_t(hero_newstep)) //floor
14026 63 hero_newstep = floor((double)hero_newstep);
14027 else --hero_newstep;
14028 63 }
14029 else
14030 63 break;
14031 67 }
14032 339 else walkable = true;
14033
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 339 times.
406 }
14034 406 while(!walkable);
14035 }
14036
14037 674 int32_t s=shiftdir;
14038
14039
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
674 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14040 {
14041 shiftdir=-1;
14042 }
14043 else
14044 {
14045
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 446 times.
674 if(s==left)
14046 {
14047 228 do
14048 {
14049 230 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14050
14051 230 execute(info);
14052
14053
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 227 times.
230 if(info.isUnwalkable())
14054 {
14055
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(x != x.getInt())
14056 {
14057 1 x.doRound();
14058 1 }
14059
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(hero_newstep_diag > 1)
14060 {
14061
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14062 1 hero_newstep_diag.doFloor();
14063 else --hero_newstep_diag;
14064 1 }
14065 else
14066 1 shiftdir = -1;
14067 3 }
14068
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 190 times.
227 else if(walkable)
14069 {
14070 37 do
14071 {
14072 37 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14073 37 execute(info);
14074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(info.isUnwalkable())
14075 {
14076 if(x != x.getInt())
14077 {
14078 x.doRound();
14079 }
14080 else if(hero_newstep_diag > 1)
14081 {
14082 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14083 hero_newstep_diag.doFloor();
14084 else --hero_newstep_diag;
14085 }
14086 else
14087 shiftdir = -1;
14088 }
14089 37 else break;
14090 }
14091 while(shiftdir != -1);
14092 37 break;
14093 }
14094 190 else break;
14095
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 }
14096 3 while(shiftdir != -1);
14097 228 }
14098
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 96 times.
446 else if(s==right)
14099 {
14100 96 do
14101 {
14102 98 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14103
14104 98 execute(info);
14105
14106
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 94 times.
98 if(info.isUnwalkable())
14107 {
14108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(x != x.getInt())
14109 {
14110 x.doRound();
14111 }
14112
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14113 {
14114
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14115 2 hero_newstep_diag.doFloor();
14116 else --hero_newstep_diag;
14117 2 }
14118 else
14119 2 shiftdir = -1;
14120 4 }
14121
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 80 times.
94 else if(walkable)
14122 {
14123 14 do
14124 {
14125 16 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14126 16 execute(info);
14127
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(info.isUnwalkable())
14128 {
14129
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(x != x.getInt())
14130 {
14131 1 x.doRound();
14132 1 }
14133
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(hero_newstep_diag > 1)
14134 {
14135
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14136 1 hero_newstep_diag.doFloor();
14137 else --hero_newstep_diag;
14138 1 }
14139 else
14140 1 shiftdir = -1;
14141 3 }
14142 13 else break;
14143
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 }
14144 3 while(shiftdir != -1);
14145 14 break;
14146 }
14147 80 else break;
14148
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 }
14149 4 while(shiftdir != -1);
14150 96 }
14151 }
14152
14153 674 move(up);
14154 674 shiftdir=s;
14155
14156
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 335 times.
674 if(!walkable)
14157 {
14158
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 65 times.
335 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14159 {
14160 65 x = x.getInt();
14161 65 y = y.getInt();
14162
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 65 times.
100 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14163
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
35 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14164
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14165 {
14166 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14167 sprite::move((zfix)-1,(zfix)0);
14168 }
14169 else
14170 {
14171
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 65 times.
95 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14172
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14173 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14174 {
14175 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14176 sprite::move((zfix)1,(zfix)0);
14177 }
14178 else
14179 {
14180 65 pushing=push+1;
14181 }
14182 }
14183 65 }
14184 else
14185 {
14186 270 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14187 }
14188 335 }
14189
14190 674 return;
14191 }
14192 }
14193
14194
6/6
✓ Branch 0 taken 1059 times.
✓ Branch 1 taken 7504 times.
✓ Branch 2 taken 1033 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 731 times.
✓ Branch 5 taken 302 times.
8563 if(DrunkDown()&&(holddir==-1||holddir==down))
14195 {
14196
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
757 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14197 {
14198 }
14199 else
14200 {
14201
4/10
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 757 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 757 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
757 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14202 {
14203 757 dir=down;
14204 757 }
14205
14206 757 holddir=down;
14207
14208
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 671 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
757 if(DrunkRight()&&shiftdir!=left)
14209 {
14210 86 shiftdir=right;
14211
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
86 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14212
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
86 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14213 86 }
14214
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 609 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 61 times.
671 else if(DrunkLeft()&&shiftdir!=right)
14215 {
14216 61 shiftdir=left;
14217
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14218
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14219 61 }
14220 else
14221 {
14222 610 shiftdir=-1;
14223 }
14224
14225 //bool walkable;
14226
8/12
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 477 times.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 137 times.
✓ Branch 6 taken 143 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 143 times.
757 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14227 {
14228 143 walkable=false;
14229 143 }
14230 else
14231 {
14232 614 do
14233 {
14234 861 info = walkflag(x,15+(y+hero_newstep),2,down);
14235
14236
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 140 times.
861 if(x.getFloor() & 7)
14237 721 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14238 else
14239 140 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14240
14241 861 execute(info);
14242
14243
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 377 times.
861 if(info.isUnwalkable())
14244 {
14245
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 478 times.
484 if(y != y.getInt())
14246 {
14247 6 y.doRound();
14248 6 }
14249
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 237 times.
478 else if(hero_newstep > 1)
14250 {
14251
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(hero_newstep != int32_t(hero_newstep)) //floor
14252 241 hero_newstep = floor((double)hero_newstep);
14253 else --hero_newstep;
14254 241 }
14255 else
14256 237 break;
14257 247 }
14258 377 else walkable = true;
14259
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 377 times.
624 }
14260 624 while(!walkable);
14261 }
14262
14263 757 int32_t s=shiftdir;
14264
14265
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
757 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14266 {
14267 shiftdir=-1;
14268 }
14269 else
14270 {
14271
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 696 times.
757 if(s==left)
14272 {
14273 61 do
14274 {
14275 61 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14276
14277 61 execute(info);
14278
14279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(info.isUnwalkable())
14280 {
14281 if(x != x.getInt())
14282 {
14283 x.doRound();
14284 }
14285 else if(hero_newstep_diag > 1)
14286 {
14287 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14288 hero_newstep_diag.doFloor();
14289 else --hero_newstep_diag;
14290 }
14291 else
14292 shiftdir = -1;
14293 }
14294
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 55 times.
61 else if(walkable)
14295 {
14296 6 do
14297 {
14298 6 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14299 6 execute(info);
14300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(info.isUnwalkable())
14301 {
14302 if(x != x.getInt())
14303 {
14304 x.doRound();
14305 }
14306 else if(hero_newstep_diag > 1)
14307 {
14308 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14309 hero_newstep_diag.doFloor();
14310 else --hero_newstep_diag;
14311 }
14312 else
14313 shiftdir = -1;
14314 }
14315 6 else break;
14316 }
14317 while(shiftdir != -1);
14318 6 break;
14319 }
14320 55 else break;
14321 }
14322 while(shiftdir != -1);
14323 61 }
14324
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 86 times.
696 else if(s==right)
14325 {
14326 86 do
14327 {
14328 91 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14329
14330 91 execute(info);
14331
14332
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 83 times.
91 if(info.isUnwalkable())
14333 {
14334
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 if(x != x.getInt())
14335 {
14336 1 x.doRound();
14337 1 }
14338
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 else if(hero_newstep_diag > 1)
14339 {
14340
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14341 4 hero_newstep_diag.doFloor();
14342 else --hero_newstep_diag;
14343 4 }
14344 else
14345 3 shiftdir = -1;
14346 8 }
14347
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 70 times.
83 else if(walkable)
14348 {
14349 13 do
14350 {
14351 13 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14352 13 execute(info);
14353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(info.isUnwalkable())
14354 {
14355 if(x != x.getInt())
14356 {
14357 x.doRound();
14358 }
14359 else if(hero_newstep_diag > 1)
14360 {
14361 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14362 hero_newstep_diag.doFloor();
14363 else --hero_newstep_diag;
14364 }
14365 else
14366 shiftdir = -1;
14367 }
14368 13 else break;
14369 }
14370 while(shiftdir != -1);
14371 13 break;
14372 }
14373 70 else break;
14374
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 }
14375 8 while(shiftdir != -1);
14376 86 }
14377 }
14378
14379 757 move(down);
14380 757 shiftdir=s;
14381
14382
2/2
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 380 times.
757 if(!walkable)
14383 {
14384
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 255 times.
380 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14385 {
14386 255 x = x.getInt();
14387 255 y = y.getInt();
14388
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✓ Branch 5 taken 148 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 255 times.
403 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14389
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 132 times.
148 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14390
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14391 {
14392 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14393 sprite::move((zfix)-1,(zfix)0);
14394 }
14395
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 107 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 255 times.
362 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14396
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✗ Branch 5 not taken.
107 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14397 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14398 {
14399 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14400 sprite::move((zfix)1,(zfix)0);
14401 }
14402 else
14403 {
14404 255 pushing=push+1;
14405 }
14406 255 }
14407 else
14408 {
14409 125 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14410 }
14411 380 }
14412
14413 757 return;
14414 }
14415 }
14416
14417
6/6
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 5621 times.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 2123 times.
✓ Branch 5 taken 2 times.
7806 if(DrunkLeft()&&(holddir==-1||holddir==left))
14418 {
14419
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2183 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2183 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14420 {
14421 }
14422 else
14423 {
14424
3/6
✓ Branch 0 taken 2183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2183 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2183 times.
2183 if(charging==0 && spins==0 && action != sideswimattacking)
14425 {
14426 2183 dir=left;
14427 2183 }
14428 2183 sideswimdir = left;
14429
14430 2183 holddir=left;
14431
14432
3/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 2123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
2183 if(DrunkUp()&&shiftdir!=down)
14433 {
14434 60 shiftdir=up;
14435 60 }
14436
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 2023 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
2123 else if(DrunkDown()&&shiftdir!=up)
14437 {
14438 100 shiftdir=down;
14439 100 }
14440 else
14441 {
14442 2023 shiftdir=-1;
14443 }
14444
14445 2183 do
14446 {
14447 2251 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14448
14449 2251 info = info || walkflag(x-hero_newstep,y+15,1,left);
14450
14451 2251 execute(info);
14452
14453
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2117 times.
2251 if(info.isUnwalkable())
14454 {
14455
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 132 times.
134 if(x != x.getInt())
14456 {
14457 2 x.doRound();
14458 2 }
14459
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 66 times.
132 else if(hero_newstep > 1)
14460 {
14461
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(hero_newstep != int32_t(hero_newstep)) //floor
14462 66 hero_newstep = floor((double)hero_newstep);
14463 else --hero_newstep;
14464 66 }
14465 else
14466 66 break;
14467 68 }
14468 2117 else walkable = true;
14469
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 2117 times.
2185 }
14470 2185 while(!walkable);
14471
14472 2183 int32_t s=shiftdir;
14473
14474
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 2183 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1972 times.
✓ Branch 7 taken 211 times.
✓ Branch 8 taken 1931 times.
✓ Branch 9 taken 41 times.
✓ Branch 10 taken 1931 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1931 times.
✗ Branch 13 not taken.
2183 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14475 {
14476 1931 shiftdir=-1;
14477 1931 }
14478 else
14479 {
14480
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 40 times.
252 if(s==up)
14481 {
14482 40 do
14483 {
14484 40 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14485
14486 40 execute(info);
14487
14488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(info.isUnwalkable())
14489 {
14490 if(y != y.getInt())
14491 {
14492 y.doRound();
14493 }
14494 else if(hero_newstep_diag > 1)
14495 {
14496 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14497 hero_newstep_diag.doFloor();
14498 else --hero_newstep_diag;
14499 }
14500 else
14501 shiftdir = -1;
14502 }
14503
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 else if(walkable)
14504 {
14505 40 do
14506 {
14507 40 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14508 40 execute(info);
14509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(info.isUnwalkable())
14510 {
14511 if(y != y.getInt())
14512 {
14513 y.doRound();
14514 }
14515 else if(hero_newstep_diag > 1)
14516 {
14517 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14518 hero_newstep_diag.doFloor();
14519 else --hero_newstep_diag;
14520 }
14521 else
14522 shiftdir = -1;
14523 }
14524 40 else break;
14525 }
14526 while(shiftdir != -1);
14527 40 break;
14528 }
14529 else break;
14530 }
14531 while(shiftdir != -1);
14532 40 }
14533
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 45 times.
212 else if(s==down)
14534 {
14535 45 do
14536 {
14537 45 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14538
14539 45 execute(info);
14540
14541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(info.isUnwalkable())
14542 {
14543 if(y != y.getInt())
14544 {
14545 y.doRound();
14546 }
14547 else if(hero_newstep_diag > 1)
14548 {
14549 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14550 hero_newstep_diag.doFloor();
14551 else --hero_newstep_diag;
14552 }
14553 else
14554 shiftdir = -1;
14555 }
14556
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 16 times.
45 else if(walkable)
14557 {
14558 29 do
14559 {
14560 29 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14561 29 execute(info);
14562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(info.isUnwalkable())
14563 {
14564 if(y != y.getInt())
14565 {
14566 y.doRound();
14567 }
14568 else if(hero_newstep_diag > 1)
14569 {
14570 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14571 hero_newstep_diag.doFloor();
14572 else --hero_newstep_diag;
14573 }
14574 else
14575 shiftdir = -1;
14576 }
14577 29 else break;
14578 }
14579 while(shiftdir != -1);
14580 29 break;
14581 }
14582 16 else break;
14583 }
14584 while(shiftdir != -1);
14585 45 }
14586 }
14587
14588 2183 move(left);
14589 2183 shiftdir=s;
14590
14591
2/2
✓ Branch 0 taken 2117 times.
✓ Branch 1 taken 66 times.
2183 if(!walkable)
14592 {
14593
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 50 times.
66 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14594 {
14595 50 x = x.getInt();
14596 50 y = y.getInt();
14597 50 int32_t v1=bigHitbox?0:8;
14598 50 int32_t v2=bigHitbox?8:12;
14599
14600
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 49 times.
53 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
14601
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
3 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
14602
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
14603 {
14604
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
14605 1 sprite::move((zfix)0,(zfix)-1);
14606 1 }
14607
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 49 times.
96 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
14608
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
14609 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
14610 {
14611 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
14612 sprite::move((zfix)0,(zfix)1);
14613 }
14614 else
14615 {
14616 49 pushing=push+1;
14617 }
14618 50 }
14619 else
14620 {
14621 16 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14622
14623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(action!=swimming)
14624 {
14625 16 }
14626 }
14627 66 }
14628
14629 2183 return;
14630 }
14631 }
14632
14633
5/6
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 2505 times.
✓ Branch 2 taken 3042 times.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 3042 times.
✗ Branch 5 not taken.
5623 if(DrunkRight()&&(holddir==-1||holddir==right))
14634 {
14635
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3118 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14636 {
14637 }
14638 else
14639 {
14640
3/6
✓ Branch 0 taken 3118 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3118 times.
3118 if(charging==0 && spins==0 && action != sideswimattacking)
14641 {
14642 3118 dir=right;
14643 3118 }
14644 3118 sideswimdir = right;
14645
14646 3118 holddir=right;
14647
14648
3/4
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 2863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 255 times.
3118 if(DrunkUp()&&shiftdir!=down)
14649 {
14650 255 shiftdir=up;
14651 255 }
14652
3/4
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 2661 times.
✓ Branch 2 taken 202 times.
✗ Branch 3 not taken.
2863 else if(DrunkDown()&&shiftdir!=up)
14653 {
14654 202 shiftdir=down;
14655 202 }
14656 else
14657 {
14658 2661 shiftdir=-1;
14659 }
14660
14661 3118 do
14662 {
14663 3352 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
14664
14665 3352 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
14666
14667 3352 execute(info);
14668
14669
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 2915 times.
3352 if(info.isUnwalkable())
14670 {
14671
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 426 times.
437 if(x != x.getInt())
14672 {
14673 11 x.doRound();
14674 11 }
14675
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 203 times.
426 else if(hero_newstep > 1)
14676 {
14677
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(hero_newstep != int32_t(hero_newstep)) //floor
14678 223 hero_newstep = floor((double)hero_newstep);
14679 else --hero_newstep;
14680 223 }
14681 else
14682 203 break;
14683 234 }
14684 2915 else walkable = true;
14685
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 2915 times.
3149 }
14686 3149 while(!walkable);
14687
14688 3118 int32_t s=shiftdir;
14689
14690
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2133 times.
✓ Branch 7 taken 985 times.
✓ Branch 8 taken 2127 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 2127 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2127 times.
✗ Branch 13 not taken.
3118 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14691 {
14692 2127 shiftdir=-1;
14693 2127 }
14694 else
14695 {
14696
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 229 times.
991 if(s==up)
14697 {
14698 229 do
14699 {
14700 270 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14701
14702 270 execute(info);
14703
14704
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 192 times.
270 if(info.isUnwalkable())
14705 {
14706
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 74 times.
78 if(y != y.getInt())
14707 {
14708 4 y.doRound();
14709 4 }
14710
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 37 times.
74 else if(hero_newstep_diag > 1)
14711 {
14712
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14713 37 hero_newstep_diag.doFloor();
14714 else --hero_newstep_diag;
14715 37 }
14716 else
14717 37 shiftdir = -1;
14718 78 }
14719
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 29 times.
192 else if(walkable)
14720 {
14721 163 do
14722 {
14723 163 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14724 163 execute(info);
14725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
163 if(info.isUnwalkable())
14726 {
14727 if(y != y.getInt())
14728 {
14729 y.doRound();
14730 }
14731 else if(hero_newstep_diag > 1)
14732 {
14733 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14734 hero_newstep_diag.doFloor();
14735 else --hero_newstep_diag;
14736 }
14737 else
14738 shiftdir = -1;
14739 }
14740 163 else break;
14741 }
14742 while(shiftdir != -1);
14743 163 break;
14744 }
14745 29 else break;
14746
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 37 times.
78 }
14747 78 while(shiftdir != -1);
14748 229 }
14749
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 96 times.
762 else if(s==down)
14750 {
14751 96 do
14752 {
14753 96 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14754
14755 96 execute(info);
14756
14757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(info.isUnwalkable())
14758 {
14759 if(y != y.getInt())
14760 {
14761 y.doRound();
14762 }
14763 else if(hero_newstep_diag > 1)
14764 {
14765 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14766 hero_newstep_diag.doFloor();
14767 else --hero_newstep_diag;
14768 }
14769 else
14770 shiftdir = -1;
14771 }
14772
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 53 times.
96 else if(walkable)
14773 {
14774 43 do
14775 {
14776 43 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
14777 43 execute(info);
14778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(info.isUnwalkable())
14779 {
14780 if(y != y.getInt())
14781 {
14782 y.doRound();
14783 }
14784 else if(hero_newstep_diag > 1)
14785 {
14786 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14787 hero_newstep_diag.doFloor();
14788 else --hero_newstep_diag;
14789 }
14790 else
14791 shiftdir = -1;
14792 }
14793 43 else break;
14794 }
14795 while(shiftdir != -1);
14796 43 break;
14797 }
14798 53 else break;
14799 }
14800 while(shiftdir != -1);
14801 96 }
14802 }
14803
14804 3118 move(right);
14805 3118 shiftdir=s;
14806
14807
2/2
✓ Branch 0 taken 2915 times.
✓ Branch 1 taken 203 times.
3118 if(!walkable)
14808 {
14809
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 121 times.
203 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14810 {
14811 121 x = x.getInt();
14812 121 y = y.getInt();
14813 121 int32_t v1=bigHitbox?0:8;
14814 121 int32_t v2=bigHitbox?8:12;
14815
14816
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 121 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 101 times.
149 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14817
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 20 times.
28 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
14818
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14819 {
14820
4/8
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
20 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
14821 20 sprite::move((zfix)0,(zfix)-1);
14822 20 }
14823
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 93 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101 times.
194 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14824
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
14825 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14826 {
14827 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
14828 sprite::move((zfix)0,(zfix)1);
14829 }
14830 else
14831 {
14832 101 pushing=push+1;
14833 101 z3step=2;
14834 }
14835 121 }
14836 else
14837 {
14838 82 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14839
14840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(action!=swimming)
14841 {
14842 82 }
14843 }
14844 203 }
14845
14846 3118 return;
14847 }
14848 }
14849 2505 }
14850 else
14851 {
14852 if(DrunkUp()&&(holddir==-1||holddir==up))
14853 {
14854 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14855 {
14856 }
14857 else
14858 {
14859 if(charging==0 && spins==0)
14860 {
14861 dir=up;
14862 }
14863
14864 holddir=up;
14865
14866 if(DrunkRight()&&shiftdir!=left)
14867 {
14868 shiftdir=right;
14869 }
14870 else if(DrunkLeft()&&shiftdir!=right)
14871 {
14872 shiftdir=left;
14873 }
14874 else
14875 {
14876 shiftdir=-1;
14877 }
14878
14879 //walkable if Ladder can be placed or is already placed vertically
14880 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14881 {
14882 walkable=false;
14883 }
14884 else
14885 {
14886 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14887
14888 if(x.getInt() & 7)
14889 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
14890 else
14891 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
14892
14893 execute(info);
14894
14895 if(info.isUnwalkable())
14896 {
14897 if(z3step==2)
14898 {
14899 z3step=1;
14900 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14901
14902 if(x.getInt()&7)
14903 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
14904 else
14905 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
14906
14907 execute(info);
14908
14909 if(info.isUnwalkable())
14910 {
14911 walkable = false;
14912 }
14913 else
14914 {
14915 walkable=true;
14916 }
14917 }
14918 else
14919 {
14920 walkable=false;
14921 }
14922 }
14923 else
14924 {
14925 walkable = true;
14926 }
14927 }
14928
14929 int32_t s=shiftdir;
14930
14931 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14932 {
14933 shiftdir=-1;
14934 }
14935 else
14936 {
14937 if(s==left)
14938 {
14939 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
14940 execute(info);
14941
14942 if(info.isUnwalkable())
14943 {
14944 shiftdir=-1;
14945 }
14946 else if(walkable)
14947 {
14948 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
14949 execute(info);
14950 if(info.isUnwalkable())
14951 {
14952 shiftdir=-1;
14953 }
14954 }
14955 }
14956 else if(s==right)
14957 {
14958 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
14959 execute(info);
14960
14961 if(info.isUnwalkable())
14962 {
14963 shiftdir=-1;
14964 }
14965 else if(walkable)
14966 {
14967 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
14968 execute(info);
14969
14970 if(info.isUnwalkable())
14971 {
14972 shiftdir=-1;
14973 }
14974 }
14975 }
14976 }
14977
14978 move(up);
14979 shiftdir=s;
14980
14981 if(!walkable)
14982 {
14983 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14984 {
14985 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14986 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14987 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14988 {
14989 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14990 sprite::move((zfix)-1,(zfix)0);
14991 }
14992 else
14993 {
14994 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14995 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14996 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14997 {
14998 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14999 sprite::move((zfix)1,(zfix)0);
15000 }
15001 else
15002 {
15003 pushing=push+1;
15004 }
15005 }
15006
15007 z3step=2;
15008 }
15009 else
15010 {
15011 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15012 z3step=2;
15013 }
15014 }
15015
15016 return;
15017 }
15018 }
15019
15020 if(DrunkDown()&&(holddir==-1||holddir==down))
15021 {
15022 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15023 {
15024 }
15025 else
15026 {
15027 if(charging==0 && spins==0)
15028 {
15029 dir=down;
15030 }
15031
15032 holddir=down;
15033
15034 if(DrunkRight()&&shiftdir!=left)
15035 {
15036 shiftdir=right;
15037 }
15038 else if(DrunkLeft()&&shiftdir!=right)
15039 {
15040 shiftdir=left;
15041 }
15042 else
15043 {
15044 shiftdir=-1;
15045 }
15046
15047 //bool walkable;
15048 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15049 {
15050 walkable=false;
15051 }
15052 else
15053 {
15054 info = walkflag(x,y+15+z3step,2,down);
15055
15056 if(x.getInt()&7)
15057 info = info || walkflag(x+16,y+15+z3step,1,down);
15058 else
15059 info = info || walkflagMBlock(x+16, y+15+z3step);
15060
15061 execute(info);
15062
15063 if(info.isUnwalkable())
15064 {
15065 if(z3step==2)
15066 {
15067 z3step=1;
15068 info = walkflag(x,y+15+z3step,2,down);
15069
15070 if(x.getInt()&7)
15071 info = info || walkflag(x+16,y+15+z3step,1,down);
15072 else
15073 info = info || walkflagMBlock(x+16, y+15+z3step);
15074
15075 execute(info);
15076
15077 if(info.isUnwalkable())
15078 {
15079 walkable = false;
15080 }
15081 else
15082 {
15083 walkable=true;
15084 }
15085 }
15086 else
15087 {
15088 walkable=false;
15089 }
15090 }
15091 else
15092 {
15093 walkable = true;
15094 }
15095 }
15096
15097 int32_t s=shiftdir;
15098
15099 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15100 {
15101 shiftdir=-1;
15102 }
15103 else
15104 {
15105 if(s==left)
15106 {
15107 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15108 execute(info);
15109
15110 if(info.isUnwalkable())
15111 {
15112 shiftdir=-1;
15113 }
15114 else if(walkable)
15115 {
15116 info = walkflag(x-1,y+16,1,left);
15117 execute(info);
15118
15119 if(info.isUnwalkable())
15120 {
15121 shiftdir=-1;
15122 }
15123 }
15124 }
15125 else if(s==right)
15126 {
15127 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15128 execute(info);
15129
15130 if(info.isUnwalkable())
15131 {
15132 shiftdir=-1;
15133 }
15134 else if(walkable)
15135 {
15136 info = walkflag(x+16,y+16,1,right);
15137 execute(info);
15138
15139 if(info.isUnwalkable())
15140 {
15141 shiftdir=-1;
15142 }
15143 }
15144 }
15145 }
15146
15147 move(down);
15148 shiftdir=s;
15149
15150 if(!walkable)
15151 {
15152 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15153 {
15154 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15155 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15156 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15157 {
15158 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15159 sprite::move((zfix)-1,(zfix)0);
15160 }
15161 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15162 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15163 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15164 {
15165 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15166 sprite::move((zfix)1,(zfix)0);
15167 }
15168 else //if(shiftdir==-1)
15169 {
15170 pushing=push+1;
15171
15172 if(action!=swimming)
15173 {
15174 }
15175 }
15176
15177 z3step=2;
15178 }
15179 else
15180 {
15181 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15182
15183 if(action!=swimming)
15184 {
15185 }
15186
15187 z3step=2;
15188 }
15189 }
15190
15191 return;
15192 }
15193 }
15194
15195 if(DrunkLeft()&&(holddir==-1||holddir==left))
15196 {
15197 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15198 {
15199 }
15200 else
15201 {
15202 if(charging==0 && spins==0)
15203 {
15204 dir=left;
15205 }
15206
15207 holddir=left;
15208
15209 if(DrunkUp()&&shiftdir!=down)
15210 {
15211 shiftdir=up;
15212 }
15213 else if(DrunkDown()&&shiftdir!=up)
15214 {
15215 shiftdir=down;
15216 }
15217 else
15218 {
15219 shiftdir=-1;
15220 }
15221
15222 //bool walkable;
15223 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15224
15225 if(y.getInt()&7)
15226 info = info || walkflag(x-z3step,y+16,1,left);
15227
15228 execute(info);
15229
15230 if(info.isUnwalkable())
15231 {
15232 if(z3step==2)
15233 {
15234 z3step=1;
15235 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15236
15237 if(y.getInt()&7)
15238 info = info || walkflag(x-z3step,y+16,1,left);
15239
15240 execute(info);
15241
15242 if(info.isUnwalkable())
15243 {
15244 walkable = false;
15245 }
15246 else
15247 {
15248 walkable=true;
15249 }
15250 }
15251 else
15252 {
15253 walkable=false;
15254 }
15255 }
15256 else
15257 {
15258 walkable = true;
15259 }
15260
15261 int32_t s=shiftdir;
15262
15263 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15264 {
15265 shiftdir=-1;
15266 }
15267 else
15268 {
15269 if(s==up)
15270 {
15271 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15272 execute(info);
15273
15274 if(info.isUnwalkable())
15275 {
15276 shiftdir=-1;
15277 }
15278 else if(walkable)
15279 {
15280 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15281 execute(info);
15282
15283 if(info.isUnwalkable())
15284 {
15285 shiftdir=-1;
15286 }
15287 }
15288 }
15289 else if(s==down)
15290 {
15291 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15292 execute(info);
15293
15294 if(info.isUnwalkable())
15295 {
15296 shiftdir=-1;
15297 }
15298 else if(walkable)
15299 {
15300 info = walkflag(x-1,y+16,1,down);
15301 execute(info);
15302
15303 if(info.isUnwalkable())
15304 {
15305 shiftdir=-1;
15306 }
15307 }
15308 }
15309 }
15310
15311 move(left);
15312 shiftdir=s;
15313
15314 if(!walkable)
15315 {
15316 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15317 {
15318 int32_t v1=bigHitbox?0:8;
15319 int32_t v2=bigHitbox?8:12;
15320
15321 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15322 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15323 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15324 {
15325 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15326 sprite::move((zfix)0,(zfix)-1);
15327 }
15328 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15329 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15330 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15331 {
15332 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15333 sprite::move((zfix)0,(zfix)1);
15334 }
15335 else //if(shiftdir==-1)
15336 {
15337 pushing=push+1;
15338
15339 if(action!=swimming)
15340 {
15341 }
15342 }
15343
15344 z3step=2;
15345 }
15346 else
15347 {
15348 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15349
15350 if(action!=swimming)
15351 {
15352 }
15353
15354 z3step=2;
15355 }
15356 }
15357
15358 return;
15359 }
15360 }
15361
15362 if(DrunkRight()&&(holddir==-1||holddir==right))
15363 {
15364 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15365 {
15366 }
15367 else
15368 {
15369 if(charging==0 && spins==0)
15370 {
15371 dir=right;
15372 }
15373
15374 holddir=right;
15375
15376 if(DrunkUp()&&shiftdir!=down)
15377 {
15378 shiftdir=up;
15379 }
15380 else if(DrunkDown()&&shiftdir!=up)
15381 {
15382 shiftdir=down;
15383 }
15384 else
15385 {
15386 shiftdir=-1;
15387 }
15388
15389 //bool walkable;
15390 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15391
15392 if(y.getInt()&7)
15393 info = info || walkflag(x+15+z3step,y+16,1,right);
15394
15395 execute(info);
15396
15397 if(info.isUnwalkable())
15398 {
15399 if(z3step==2)
15400 {
15401 z3step=1;
15402 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15403
15404 if(y.getInt()&7)
15405 info = info || walkflag(x+15+z3step,y+16,1,right);
15406
15407 execute(info);
15408
15409 if(info.isUnwalkable())
15410 {
15411 walkable = false;
15412 }
15413 else
15414 {
15415 walkable=true;
15416 }
15417 }
15418 else
15419 {
15420 walkable=false;
15421 }
15422 }
15423 else
15424 {
15425 walkable = true;
15426 }
15427
15428 int32_t s=shiftdir;
15429
15430 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15431 {
15432 shiftdir=-1;
15433 }
15434 else
15435 {
15436 if(s==up)
15437 {
15438 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15439 execute(info);
15440
15441 if(info.isUnwalkable())
15442 {
15443 shiftdir=-1;
15444 }
15445 else if(walkable)
15446 {
15447 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15448 execute(info);
15449
15450 if(info.isUnwalkable())
15451 {
15452 shiftdir=-1;
15453 }
15454 }
15455 }
15456 else if(s==down)
15457 {
15458 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15459 execute(info);
15460
15461 if(info.isUnwalkable())
15462 {
15463 shiftdir=-1;
15464 }
15465 else if(walkable)
15466 {
15467 info = walkflag(x+16,y+16,1,down);
15468 execute(info);
15469
15470 if(info.isUnwalkable())
15471 {
15472 shiftdir=-1;
15473 }
15474 }
15475 }
15476 }
15477
15478 move(right);
15479 shiftdir=s;
15480
15481 if(!walkable)
15482 {
15483 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15484 {
15485 int32_t v1=bigHitbox?0:8;
15486 int32_t v2=bigHitbox?8:12;
15487
15488 info = !walkflag(x+16,y+v1,1,right)&&
15489 !walkflag(x+16,y+v2,1,right)&&
15490 walkflag(x+16,y+15,1,right);
15491
15492 //do NOT execute these
15493 if(info.isUnwalkable())
15494 {
15495 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15496 sprite::move((zfix)0,(zfix)-1);
15497 }
15498 else
15499 {
15500 info = walkflag(x+16,y+v1, 1,right)&&
15501 !walkflag(x+16,y+v2-1,1,right)&&
15502 !walkflag(x+16,y+15, 1,right);
15503
15504 if(info.isUnwalkable())
15505 {
15506 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15507 sprite::move((zfix)0,(zfix)1);
15508 }
15509 else //if(shiftdir==-1)
15510 {
15511 pushing=push+1;
15512 z3step=2;
15513
15514 if(action!=swimming)
15515 {
15516 }
15517 }
15518 }
15519
15520 z3step=2;
15521 }
15522 else
15523 {
15524 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15525
15526 if(action!=swimming)
15527 {
15528 }
15529
15530 z3step=2;
15531 }
15532 }
15533
15534 return;
15535 }
15536 }
15537 }
15538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2505 if(shield_forcedir > -1 && action != rafting)
15539 dir = shield_forcedir;
15540 2505 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15541 2505 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15542 2505 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15543 2505 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15544 2505 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15545
15546
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 2505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
2505 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15547 {
15548 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15549 {
15550 //action=swimming;
15551 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15552 {
15553 hopclk = 0xFF;
15554 }
15555 }
15556 }
15557
15558 2505 return;
15559 } //endif (LTTPWALK)
15560 663672 temp_step = hero_newstep;
15561 663672 temp_x = x;
15562 663672 temp_y = y;
15563
15564
7/8
✓ Branch 0 taken 529408 times.
✓ Branch 1 taken 134264 times.
✓ Branch 2 taken 523764 times.
✓ Branch 3 taken 5644 times.
✓ Branch 4 taken 4821 times.
✓ Branch 5 taken 524587 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4821 times.
663672 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15565 {
15566
2/4
✓ Branch 0 taken 4821 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4821 times.
4821 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15567 goto LEFTRIGHT_NEWMOVE;
15568 4821 else goto LEFTRIGHT_OLDMOVE;
15569 }
15570
15571 // make it easier to get in left & right doors
15572
15573 //ignore ladder for this part. sigh sigh sigh -DD
15574 658851 oldladderx = ladderx;
15575 658851 oldladdery = laddery;
15576
2/4
✓ Branch 0 taken 658851 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 658851 times.
658851 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15577 {
15578 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
15579 {
15580 do
15581 {
15582 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
15583 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
15584
15585 if(info.isUnwalkable())
15586 {
15587 if(temp_x != int32_t(temp_x))
15588 {
15589 temp_x = floor((double)temp_x);
15590 }
15591 else if(temp_step > 1)
15592 {
15593 if(temp_step != int32_t(temp_step)) //floor
15594 temp_step = floor((double)temp_step);
15595 else --temp_step;
15596 }
15597 else
15598 break;
15599 }
15600 }
15601 while(info.isUnwalkable());
15602
15603 if(!info.isUnwalkable())
15604 {
15605 x = temp_x;
15606 y = temp_y;
15607 hero_newstep = temp_step;
15608 //ONLY process the side-effects of the above walkflag if Hero will actually move
15609 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
15610 execute(info);
15611 move(left);
15612 return;
15613 }
15614 temp_x = x;
15615 temp_y = y;
15616 temp_step = hero_newstep;
15617 }
15618
15619 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
15620 {
15621 do
15622 {
15623 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
15624 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15625
15626 if(info.isUnwalkable())
15627 {
15628 if(temp_x != int32_t(temp_x))
15629 {
15630 temp_x = floor((double)temp_x);
15631 }
15632 else if(temp_step > 1)
15633 {
15634 if(temp_step != int32_t(temp_step)) //floor
15635 temp_step = floor((double)temp_step);
15636 else --temp_step;
15637 }
15638 else
15639 break;
15640 }
15641 }
15642 while(info.isUnwalkable());
15643
15644 if(!info.isUnwalkable())
15645 {
15646 x = temp_x;
15647 y = temp_y;
15648 hero_newstep = temp_step;
15649 execute(info);
15650 move(right);
15651 return;
15652 }
15653 temp_x = x;
15654 temp_y = y;
15655 temp_step = hero_newstep;
15656 }
15657
15658 ladderx = oldladderx;
15659 laddery = oldladdery;
15660
15661 if(DrunkUp())
15662 {
15663 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15664 {
15665 if(dir!=up && dir!=down)
15666 {
15667 if(xoff>2&&xoff<6)
15668 {
15669 move(dir);
15670 }
15671 else if(xoff>=6)
15672 {
15673 move(right);
15674 }
15675 else if(xoff>=1)
15676 {
15677 move(left);
15678 }
15679 }
15680 else
15681 {
15682 if(xoff>=4)
15683 {
15684 move(right);
15685 }
15686 else if(xoff<4)
15687 {
15688 move(left);
15689 }
15690 }
15691 }
15692 else
15693 {
15694 do
15695 {
15696 if(action==swimming || IsSideSwim() || action == swimhit)
15697 {
15698 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15699
15700 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
15701 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
15702 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
15703 info.setUnwalkable(true);
15704 }
15705 else
15706 {
15707 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15708 if(x.getInt() & 7)
15709 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
15710 else
15711 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15712 }
15713
15714 if(info.isUnwalkable())
15715 {
15716 if(temp_y != int32_t(temp_y))
15717 {
15718 temp_y = floor((double)temp_y);
15719 }
15720 else if(temp_step > 1)
15721 {
15722 if(temp_step != int32_t(temp_step)) //floor
15723 temp_step = floor((double)temp_step);
15724 else --temp_step;
15725 }
15726 else
15727 break;
15728 }
15729 }
15730 while(info.isUnwalkable());
15731
15732 execute(info);
15733
15734 if(!info.isUnwalkable())
15735 {
15736 x = temp_x;
15737 y = temp_y;
15738 hero_newstep = temp_step;
15739 move(up);
15740 return;
15741 }
15742
15743 if(!DrunkLeft() && !DrunkRight())
15744 {
15745 if(NO_GRIDLOCK)
15746 {
15747 x = x.getInt();
15748 y = y.getInt();
15749 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15750 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15751 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15752 {
15753 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15754 sprite::move((zfix)-1,(zfix)0);
15755 }
15756 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15757 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15758 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15759 {
15760 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15761 sprite::move((zfix)1,(zfix)0);
15762 }
15763 else
15764 {
15765 pushing=push+1;
15766 }
15767 }
15768 else pushing=push+1;
15769
15770 if(charging==0 && spins==0)
15771 {
15772 dir=up;
15773 }
15774
15775 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15776 {
15777 herostep();
15778 }
15779
15780 return;
15781 }
15782 else
15783 {
15784 goto LEFTRIGHT_NEWMOVE;
15785 }
15786 }
15787
15788 return;
15789 }
15790
15791 if(DrunkDown())
15792 {
15793 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15794 {
15795 if(dir!=up && dir!=down)
15796 {
15797 if(xoff>2&&xoff<6)
15798 {
15799 move(dir);
15800 }
15801 else if(xoff>=6)
15802 {
15803 move(right);
15804 }
15805 else if(xoff>=1)
15806 {
15807 move(left);
15808 }
15809 }
15810 else
15811 {
15812 if(xoff>=4)
15813 {
15814 move(right);
15815 }
15816 else if(xoff<4)
15817 {
15818 move(left);
15819 }
15820 }
15821 }
15822 else
15823 {
15824 do
15825 {
15826 if(action==swimming || IsSideSwim() || action == swimhit)
15827 {
15828 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15829
15830 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
15831 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
15832 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
15833 info.setUnwalkable(true);
15834 }
15835 else
15836 {
15837 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15838 if(x.getInt() & 7)
15839 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
15840 else
15841 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15842 }
15843
15844 if(info.isUnwalkable())
15845 {
15846 if(temp_y != int32_t(temp_y))
15847 {
15848 temp_y = floor((double)temp_y);
15849 }
15850 else if(temp_step > 1)
15851 {
15852 if(temp_step != int32_t(temp_step)) //floor
15853 temp_step = floor((double)temp_step);
15854 else --temp_step;
15855 }
15856 else
15857 break;
15858 }
15859 }
15860 while(info.isUnwalkable());
15861
15862 execute(info);
15863
15864 if(!info.isUnwalkable())
15865 {
15866 x = temp_x;
15867 y = temp_y;
15868 hero_newstep = temp_step;
15869 move(down);
15870 return;
15871 }
15872
15873 if(!DrunkLeft() && !DrunkRight())
15874 {
15875 if(NO_GRIDLOCK)
15876 {
15877 x = x.getInt();
15878 y = y.getInt();
15879 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15880 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15881 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15882 {
15883 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15884 sprite::move((zfix)-1,(zfix)0);
15885 }
15886 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15887 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15888 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15889 {
15890 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15891 sprite::move((zfix)1,(zfix)0);
15892 }
15893 else
15894 {
15895 pushing=push+1;
15896 }
15897 }
15898 else pushing=push+1;
15899
15900 if(charging==0 && spins==0)
15901 {
15902 dir=down;
15903 }
15904
15905 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15906 {
15907 herostep();
15908 }
15909
15910 return;
15911 }
15912 else goto LEFTRIGHT_NEWMOVE;
15913 }
15914
15915 return;
15916 }
15917
15918 LEFTRIGHT_NEWMOVE:
15919 temp_x = x;
15920 temp_y = y;
15921 temp_step = hero_newstep;
15922 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15923 {
15924 return;
15925 }
15926
15927 if(DrunkLeft())
15928 {
15929 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15930 {
15931 if(dir!=left && dir!=right)
15932 {
15933 if(yoff>2&&yoff<6)
15934 {
15935 move(dir);
15936 }
15937 else if(yoff>=6)
15938 {
15939 move(down);
15940 }
15941 else if(yoff>=1)
15942 {
15943 move(up);
15944 }
15945 }
15946 else
15947 {
15948 if(yoff>=4)
15949 {
15950 move(down);
15951 }
15952 else if(yoff<4)
15953 {
15954 move(up);
15955 }
15956 }
15957 }
15958 else
15959 {
15960 do
15961 {
15962 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
15963 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
15964
15965 if(y.getInt() & 7)
15966 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
15967
15968 if(info.isUnwalkable())
15969 {
15970 if(temp_x != int32_t(temp_x))
15971 {
15972 temp_x = floor((double)temp_x);
15973 }
15974 else if(temp_step > 1)
15975 {
15976 if(temp_step != int32_t(temp_step)) //floor
15977 temp_step = floor((double)temp_step);
15978 else --temp_step;
15979 }
15980 else
15981 break;
15982 }
15983 }
15984 while(info.isUnwalkable());
15985
15986 execute(info);
15987
15988 if(!info.isUnwalkable())
15989 {
15990 x = temp_x;
15991 y = temp_y;
15992 hero_newstep = temp_step;
15993 move(left);
15994 return;
15995 }
15996
15997 if(!DrunkUp() && !DrunkDown())
15998 {
15999 if(NO_GRIDLOCK)
16000 {
16001 x = x.getInt();
16002 y = y.getInt();
16003 int32_t v1=bigHitbox?0:8;
16004 int32_t v2=bigHitbox?8:12;
16005
16006 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16007 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16008 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16009 {
16010 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16011 sprite::move((zfix)0,(zfix)-1);
16012 }
16013 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16014 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16015 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16016 {
16017 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16018 sprite::move((zfix)0,(zfix)1);
16019 }
16020 else
16021 {
16022 pushing=push+1;
16023 }
16024 }
16025 else pushing=push+1;
16026
16027 if(charging==0 && spins==0)
16028 {
16029 dir=left;
16030 }
16031
16032 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16033 {
16034 herostep();
16035 }
16036
16037 return;
16038 }
16039 }
16040
16041 return;
16042 }
16043
16044 if(DrunkRight())
16045 {
16046 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16047 {
16048 if(dir!=left && dir!=right)
16049 {
16050 if(yoff>2&&yoff<6)
16051 {
16052 move(dir);
16053 }
16054 else if(yoff>=6)
16055 {
16056 move(down);
16057 }
16058 else if(yoff>=1)
16059 {
16060 move(up);
16061 }
16062 }
16063 else
16064 {
16065 if(yoff>=4)
16066 {
16067 move(down);
16068 }
16069 else if(yoff<4)
16070 {
16071 move(up);
16072 }
16073 }
16074 }
16075 else
16076 {
16077 do
16078 {
16079 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16080 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16081
16082 if(y.getInt() & 7)
16083 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16084
16085 if(info.isUnwalkable())
16086 {
16087 if(temp_x != int32_t(temp_x))
16088 {
16089 temp_x = floor((double)temp_x);
16090 }
16091 else if(temp_step > 1)
16092 {
16093 if(temp_step != int32_t(temp_step)) //floor
16094 temp_step = floor((double)temp_step);
16095 else --temp_step;
16096 }
16097 else
16098 break;
16099 }
16100 }
16101 while(info.isUnwalkable());
16102
16103 execute(info);
16104
16105 if(!info.isUnwalkable())
16106 {
16107 x = temp_x;
16108 y = temp_y;
16109 hero_newstep = temp_step;
16110 move(right);
16111 return;
16112 }
16113
16114 if(!DrunkUp() && !DrunkDown())
16115 {
16116 if(NO_GRIDLOCK)
16117 {
16118 x = x.getInt();
16119 y = y.getInt();
16120 int32_t v1=bigHitbox?0:8;
16121 int32_t v2=bigHitbox?8:12;
16122
16123 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16124 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16125 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16126 {
16127 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16128 sprite::move((zfix)0,(zfix)-1);
16129 }
16130 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16131 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16132 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16133 {
16134 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16135 sprite::move((zfix)0,(zfix)1);
16136 }
16137 else
16138 {
16139 pushing=push+1;
16140 }
16141 }
16142 else pushing=push+1;
16143
16144 if(charging==0 && spins==0)
16145 {
16146 dir=right;
16147 }
16148
16149 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16150 {
16151 herostep();
16152 }
16153
16154 return;
16155 }
16156 }
16157 }
16158 }
16159 else
16160 {
16161 1317702 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16162 658851 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16163
16164
10/10
✓ Branch 0 taken 524587 times.
✓ Branch 1 taken 134264 times.
✓ Branch 2 taken 59712 times.
✓ Branch 3 taken 464875 times.
✓ Branch 4 taken 45921 times.
✓ Branch 5 taken 13791 times.
✓ Branch 6 taken 334 times.
✓ Branch 7 taken 45587 times.
✓ Branch 8 taken 290 times.
✓ Branch 9 taken 44 times.
658851 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16165 {
16166 //ONLY process the side-effects of the above walkflag if Hero will actually move
16167 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16168 290 execute(info);
16169 290 move(left);
16170 290 return;
16171 }
16172
16173 1317122 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16174 658561 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16175
16176
10/10
✓ Branch 0 taken 524297 times.
✓ Branch 1 taken 134264 times.
✓ Branch 2 taken 64351 times.
✓ Branch 3 taken 459946 times.
✓ Branch 4 taken 48489 times.
✓ Branch 5 taken 15862 times.
✓ Branch 6 taken 410 times.
✓ Branch 7 taken 48079 times.
✓ Branch 8 taken 33 times.
✓ Branch 9 taken 377 times.
658561 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16177 {
16178 377 execute(info);
16179 377 move(right);
16180 377 return;
16181 }
16182
16183 658184 ladderx = oldladderx;
16184 658184 laddery = oldladdery;
16185
16186
2/2
✓ Branch 0 taken 74728 times.
✓ Branch 1 taken 583456 times.
658184 if(DrunkUp())
16187 {
16188
10/14
✓ Branch 0 taken 2159 times.
✓ Branch 1 taken 72569 times.
✓ Branch 2 taken 2146 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 2115 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 2115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2115 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2115 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2115 times.
74728 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16189 {
16190
2/4
✓ Branch 0 taken 2115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2115 times.
2115 if(dir!=up && dir!=down)
16191 {
16192
4/4
✓ Branch 0 taken 1448 times.
✓ Branch 1 taken 667 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 822 times.
2115 if(xoff>2&&xoff<6)
16193 {
16194 822 move(dir);
16195 822 }
16196
2/2
✓ Branch 0 taken 626 times.
✓ Branch 1 taken 667 times.
1293 else if(xoff>=6)
16197 {
16198 626 move(right);
16199 626 }
16200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
667 else if(xoff>=1)
16201 {
16202 667 move(left);
16203 667 }
16204 2115 }
16205 else
16206 {
16207 if(xoff>=4)
16208 {
16209 move(right);
16210 }
16211 else if(xoff<4)
16212 {
16213 move(left);
16214 }
16215 }
16216 2115 }
16217 else
16218 {
16219
4/6
✓ Branch 0 taken 71697 times.
✓ Branch 1 taken 916 times.
✓ Branch 2 taken 71697 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 71697 times.
72613 if(action==swimming || IsSideSwim() || action == swimhit)
16220 {
16221 916 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16222
16223
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 916 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 916 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 912 times.
✓ Branch 6 taken 860 times.
✓ Branch 7 taken 56 times.
1828 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16224
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 856 times.
1768 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16225 856 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16226 56 info.setUnwalkable(true);
16227 916 }
16228 else
16229 {
16230 71697 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16231
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 71684 times.
71697 if(x.getInt() & 7)
16232 13 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16233 else
16234 71684 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16235 }
16236
16237 72613 execute(info);
16238
16239
2/2
✓ Branch 0 taken 23283 times.
✓ Branch 1 taken 49330 times.
72613 if(!info.isUnwalkable())
16240 {
16241 49330 move(up);
16242 49330 return;
16243 }
16244
16245
4/4
✓ Branch 0 taken 22028 times.
✓ Branch 1 taken 1255 times.
✓ Branch 2 taken 1576 times.
✓ Branch 3 taken 20452 times.
23283 if(!DrunkLeft() && !DrunkRight())
16246 {
16247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20452 times.
20452 if(NO_GRIDLOCK)
16248 {
16249 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16250 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16251 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16252 {
16253 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16254 sprite::move((zfix)-1,(zfix)0);
16255 }
16256 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16257 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16258 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16259 {
16260 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16261 sprite::move((zfix)1,(zfix)0);
16262 }
16263 else
16264 {
16265 pushing=push+1;
16266 }
16267 }
16268 20452 else pushing=push+1;
16269
16270
2/4
✓ Branch 0 taken 20452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20452 times.
✗ Branch 3 not taken.
20452 if(charging==0 && spins==0)
16271 {
16272 20452 dir=up;
16273 20452 }
16274
16275
5/8
✓ Branch 0 taken 20411 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 20411 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20411 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20411 times.
20452 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16276 {
16277 20411 herostep();
16278 20411 }
16279
16280 20452 return;
16281 }
16282 else
16283 {
16284 2831 goto LEFTRIGHT_OLDMOVE;
16285 }
16286 }
16287
16288 2115 return;
16289 }
16290
16291
2/2
✓ Branch 0 taken 62476 times.
✓ Branch 1 taken 520980 times.
583456 if(DrunkDown())
16292 {
16293
9/14
✓ Branch 0 taken 1647 times.
✓ Branch 1 taken 60829 times.
✓ Branch 2 taken 1647 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1550 times.
✓ Branch 5 taken 97 times.
✓ Branch 6 taken 1550 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1550 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1550 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1550 times.
62476 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16294 {
16295
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1550 times.
1550 if(dir!=up && dir!=down)
16296 {
16297
4/4
✓ Branch 0 taken 1133 times.
✓ Branch 1 taken 417 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 650 times.
1550 if(xoff>2&&xoff<6)
16298 {
16299 650 move(dir);
16300 650 }
16301
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 417 times.
900 else if(xoff>=6)
16302 {
16303 483 move(right);
16304 483 }
16305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 else if(xoff>=1)
16306 {
16307 417 move(left);
16308 417 }
16309 1550 }
16310 else
16311 {
16312 if(xoff>=4)
16313 {
16314 move(right);
16315 }
16316 else if(xoff<4)
16317 {
16318 move(left);
16319 }
16320 }
16321 1550 }
16322 else
16323 {
16324
4/6
✓ Branch 0 taken 59355 times.
✓ Branch 1 taken 1571 times.
✓ Branch 2 taken 59355 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59355 times.
60926 if(action==swimming || IsSideSwim() || action == swimhit)
16325 {
16326 1571 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16327
16328
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1571 times.
✓ Branch 2 taken 1571 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 1497 times.
✓ Branch 6 taken 1330 times.
✓ Branch 7 taken 241 times.
3068 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16329
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 1256 times.
2753 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16330 1256 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16331 241 info.setUnwalkable(true);
16332 1571 }
16333 else
16334 {
16335 59355 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59355 times.
59355 if(x.getInt() & 7)
16337 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16338 else
16339 59355 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16340 }
16341
16342 60926 execute(info);
16343
16344
2/2
✓ Branch 0 taken 21732 times.
✓ Branch 1 taken 39194 times.
60926 if(!info.isUnwalkable())
16345 {
16346 39194 move(down);
16347 39194 return;
16348 }
16349
16350
4/4
✓ Branch 0 taken 20568 times.
✓ Branch 1 taken 1164 times.
✓ Branch 2 taken 1193 times.
✓ Branch 3 taken 19375 times.
21732 if(!DrunkLeft() && !DrunkRight())
16351 {
16352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19375 times.
19375 if(NO_GRIDLOCK)
16353 {
16354 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16355 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16356 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16357 {
16358 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16359 sprite::move((zfix)-1,(zfix)0);
16360 }
16361 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16362 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16363 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16364 {
16365 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16366 sprite::move((zfix)1,(zfix)0);
16367 }
16368 else
16369 {
16370 pushing=push+1;
16371 }
16372 }
16373 19375 else pushing=push+1;
16374
16375
2/4
✓ Branch 0 taken 19375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19375 times.
✗ Branch 3 not taken.
19375 if(charging==0 && spins==0)
16376 {
16377 19375 dir=down;
16378 19375 }
16379
16380
5/8
✓ Branch 0 taken 19210 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 19210 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19210 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 19210 times.
19375 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16381 {
16382 19210 herostep();
16383 19210 }
16384
16385 19375 return;
16386 }
16387 2357 else goto LEFTRIGHT_OLDMOVE;
16388 }
16389
16390 1550 return;
16391 }
16392
16393 LEFTRIGHT_OLDMOVE:
16394
16395
7/8
✓ Branch 0 taken 426381 times.
✓ Branch 1 taken 104608 times.
✓ Branch 2 taken 416705 times.
✓ Branch 3 taken 9676 times.
✓ Branch 4 taken 5701 times.
✓ Branch 5 taken 420680 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5701 times.
530989 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16396 {
16397 5701 return;
16398 }
16399
16400
2/2
✓ Branch 0 taken 76276 times.
✓ Branch 1 taken 449012 times.
525288 if(DrunkLeft())
16401 {
16402
9/14
✓ Branch 0 taken 1542 times.
✓ Branch 1 taken 74734 times.
✓ Branch 2 taken 1542 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1523 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 1523 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1523 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1523 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1523 times.
76276 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16403 {
16404
2/4
✓ Branch 0 taken 1523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1523 times.
1523 if(dir!=left && dir!=right)
16405 {
16406
4/4
✓ Branch 0 taken 1084 times.
✓ Branch 1 taken 439 times.
✓ Branch 2 taken 478 times.
✓ Branch 3 taken 606 times.
1523 if(yoff>2&&yoff<6)
16407 {
16408 606 move(dir);
16409 606 }
16410
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 439 times.
917 else if(yoff>=6)
16411 {
16412 478 move(down);
16413 478 }
16414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
439 else if(yoff>=1)
16415 {
16416 439 move(up);
16417 439 }
16418 1523 }
16419 else
16420 {
16421 if(yoff>=4)
16422 {
16423 move(down);
16424 }
16425 else if(yoff<4)
16426 {
16427 move(up);
16428 }
16429 }
16430 1523 }
16431 else
16432 {
16433 149506 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16434 74753 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16435
16436 74753 execute(info);
16437
16438
2/2
✓ Branch 0 taken 13328 times.
✓ Branch 1 taken 61425 times.
74753 if(!info.isUnwalkable())
16439 {
16440 61425 move(left);
16441 61425 return;
16442 }
16443
16444
4/4
✓ Branch 0 taken 13262 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 12950 times.
13328 if(!DrunkUp() && !DrunkDown())
16445 {
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12950 times.
12950 if(NO_GRIDLOCK)
16447 {
16448 int32_t v1=bigHitbox?0:8;
16449 int32_t v2=bigHitbox?8:12;
16450
16451 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16452 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16453 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16454 {
16455 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16456 sprite::move((zfix)0,(zfix)-1);
16457 }
16458 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16459 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16460 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16461 {
16462 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16463 sprite::move((zfix)0,(zfix)1);
16464 }
16465 else
16466 {
16467 pushing=push+1;
16468 }
16469 }
16470 12950 else pushing=push+1;
16471
16472
2/4
✓ Branch 0 taken 12950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12950 times.
12950 if(charging==0 && spins==0)
16473 {
16474 12950 dir=left;
16475 12950 }
16476
16477
5/8
✓ Branch 0 taken 12938 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12938 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12938 times.
12950 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16478 {
16479 12938 herostep();
16480 12938 }
16481
16482 12950 return;
16483 }
16484 }
16485
16486 1901 return;
16487 }
16488
16489
2/2
✓ Branch 0 taken 368230 times.
✓ Branch 1 taken 80782 times.
449012 if(DrunkRight())
16490 {
16491
9/14
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 79252 times.
✓ Branch 2 taken 1530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1513 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 1513 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1513 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1513 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1513 times.
80782 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16492 {
16493
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if(dir!=left && dir!=right)
16494 {
16495
4/4
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 434 times.
✓ Branch 2 taken 430 times.
✓ Branch 3 taken 649 times.
1513 if(yoff>2&&yoff<6)
16496 {
16497 649 move(dir);
16498 649 }
16499
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 434 times.
864 else if(yoff>=6)
16500 {
16501 430 move(down);
16502 430 }
16503
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 else if(yoff>=1)
16504 {
16505 434 move(up);
16506 434 }
16507 1513 }
16508 else
16509 {
16510 if(yoff>=4)
16511 {
16512 move(down);
16513 }
16514 else if(yoff<4)
16515 {
16516 move(up);
16517 }
16518 }
16519 1513 }
16520 else
16521 {
16522 158538 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16523 79269 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16524
16525 79269 execute(info);
16526
16527
2/2
✓ Branch 0 taken 16584 times.
✓ Branch 1 taken 62685 times.
79269 if(!info.isUnwalkable())
16528 {
16529 62685 move(right);
16530 62685 return;
16531 }
16532
16533
4/4
✓ Branch 0 taken 16349 times.
✓ Branch 1 taken 235 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 16204 times.
16584 if(!DrunkUp() && !DrunkDown())
16534 {
16535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16204 times.
16204 if(NO_GRIDLOCK)
16536 {
16537 int32_t v1=bigHitbox?0:8;
16538 int32_t v2=bigHitbox?8:12;
16539
16540 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16541 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16542 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16543 {
16544 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16545 sprite::move((zfix)0,(zfix)-1);
16546 }
16547 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16548 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16549 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16550 {
16551 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16552 sprite::move((zfix)0,(zfix)1);
16553 }
16554 else
16555 {
16556 pushing=push+1;
16557 }
16558 }
16559 16204 else pushing=push+1;
16560
16561
2/4
✓ Branch 0 taken 16204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16204 times.
16204 if(charging==0 && spins==0)
16562 {
16563 16204 dir=right;
16564 16204 }
16565
16566
5/8
✓ Branch 0 taken 16197 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 16197 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16197 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16197 times.
16204 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16567 {
16568 16197 herostep();
16569 16197 }
16570
16571 16204 return;
16572 }
16573 }
16574 1893 }
16575 }
16576 1906923 }
16577
16578 //solid ffc checking should probably be moved to here.
16579 1165377 void HeroClass::move(int32_t d2, int32_t forceRate)
16580 {
16581
4/6
✓ Branch 0 taken 1165337 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 1165337 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1165337 times.
1165377 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16582 40 return;
16583
16584
3/4
✓ Branch 0 taken 1158605 times.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1158605 times.
1165337 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
16585 {
16586 1158605 moveOld(d2);
16587 1158605 return;
16588 }
16589
16590
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13464 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
16591
5/6
✓ Branch 0 taken 4762 times.
✓ Branch 1 taken 1970 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 3402 times.
✓ Branch 4 taken 4762 times.
✗ Branch 5 not taken.
6732 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
16592 //!DIMITODO: add QR for slow combos under hero
16593
2/2
✓ Branch 0 taken 13464 times.
✓ Branch 1 taken 6732 times.
20196 for (int32_t i = 0; i <= 1; ++i)
16594 {
16595
2/2
✓ Branch 0 taken 12145 times.
✓ Branch 1 taken 1319 times.
13464 if(tmpscr2[i].valid!=0)
16596 {
16597
1/2
✓ Branch 0 taken 1319 times.
✗ Branch 1 not taken.
1319 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
16598 {
16599 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16600 }
16601 else
16602 {
16603
2/4
✓ Branch 0 taken 1319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1319 times.
✗ Branch 3 not taken.
1319 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16604 }
16605 1319 }
16606 13464 }
16607
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16608 6732 bool is_swimming = (action == swimming);
16609 6732 bool fastSwim = (zinit.hero_swim_speed>60);
16610 6732 zfix rate(steprate);
16611 6732 int32_t shieldid = getCurrentActiveShield();
16612
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(shieldid > -1)
16613 {
16614 itemdata const& shield = itemsbuf[shieldid];
16615 if(shield.flags & ITEM_FLAG10) //Change Speed flag
16616 {
16617 zfix perc = shield.misc7;
16618 perc /= 100;
16619 if(perc < 0)
16620 perc = (perc*-1)+1;
16621 rate = (rate * perc) + shield.misc8;
16622 }
16623 }
16624
16625 6732 zfix dx, dy;
16626 6732 zfix movepix(rate / 100);
16627 6732 zfix step(movepix);
16628 6732 zfix step_diag(movepix);
16629 6732 zfix up_step(game->get_sideswim_up() / -100.0);
16630 6732 zfix left_step(game->get_sideswim_side() / -100.0);
16631 6732 zfix right_step(game->get_sideswim_side() / 100.0);
16632 6732 zfix down_step(game->get_sideswim_down() / 100.0);
16633 6732 bool checkladder = false;
16634
16635
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(hero_newstep > movepix) hero_newstep = movepix;
16636
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
16637 //2/3 speed
16638
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✓ Branch 2 taken 6732 times.
✓ Branch 3 taken 6732 times.
✓ Branch 4 taken 6732 times.
✓ Branch 5 taken 6732 times.
6732 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
16639 {
16640 13464 step = ((step / 3.0) * 2);
16641 13464 step_diag = ((step_diag / 3.0) * 2);
16642 13464 up_step = ((up_step / 3.0) * 2);
16643 13464 left_step = ((left_step / 3.0) * 2);
16644 13464 right_step = ((right_step / 3.0) * 2);
16645 13464 down_step = ((down_step / 3.0) * 2);
16646 13464 }
16647 //1/2 speed
16648
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6732 times.
6732 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
16649 {
16650 step /= 2;
16651 step_diag /= 2;
16652 up_step /= 2;
16653 left_step /= 2;
16654 right_step /= 2;
16655 down_step /= 2;
16656 }
16657 //normal speed
16658 else
16659 {
16660 //no modification
16661 }
16662
16663
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(diagonalMovement)
16664 {
16665 //zprint2("Player's X is %d, Y is %d\n", x, y);
16666
6/6
✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 5844 times.
✓ Branch 3 taken 214 times.
✓ Branch 4 taken 1143 times.
✓ Branch 5 taken 5375 times.
11801 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
16667
4/4
✓ Branch 0 taken 4085 times.
✓ Branch 1 taken 3871 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 2887 times.
214 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
16668 {
16669
2/4
✓ Branch 0 taken 837 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 837 times.
11587 if(hero_newstep > 0 && hero_newstep_diag > 0)
16670 {
16671 837 step = STEP_DIAGONAL(step);
16672 837 step_diag = STEP_DIAGONAL(step_diag);
16673 837 up_step = STEP_DIAGONAL(up_step);
16674 837 left_step = STEP_DIAGONAL(left_step);
16675 837 right_step = STEP_DIAGONAL(right_step);
16676 837 down_step = STEP_DIAGONAL(down_step);
16677 837 }
16678 837 }
16679
2/2
✓ Branch 0 taken 3131 times.
✓ Branch 1 taken 593 times.
3724 if(hero_newstep < step) step = hero_newstep; //handle collision
16680
2/2
✓ Branch 0 taken 3679 times.
✓ Branch 1 taken 45 times.
3724 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
16681
5/5
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 757 times.
✓ Branch 3 taken 2183 times.
✓ Branch 4 taken 3118 times.
3724 switch(d2)
16682 {
16683 case up:
16684
3/3
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 93 times.
674 switch(shiftdir)
16685 {
16686 case left:
16687 227 dx = -step_diag;
16688
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 if (IsSideSwim()) dx = left_step;
16689 227 break;
16690 case right:
16691 93 dx = step_diag;
16692
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if (IsSideSwim()) dx = right_step;
16693 93 break;
16694 }
16695
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 339 times.
674 if(walkable)
16696 {
16697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if (!IsSideSwim()) dy = -step;
16698
1/2
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
339 if (IsSideSwim())
16699 {
16700 dy = up_step;
16701 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16702 }
16703 339 }
16704 674 break;
16705 case down:
16706
3/3
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 83 times.
757 switch(shiftdir)
16707 {
16708 case left:
16709 61 dx = -step_diag;
16710
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (IsSideSwim()) dx = left_step;
16711 61 break;
16712 case right:
16713 83 dx = step_diag;
16714
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if (IsSideSwim()) dx = right_step;
16715 83 break;
16716 }
16717
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 377 times.
757 if(walkable)
16718 {
16719 377 dy = step;
16720
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if (IsSideSwim()) dy = down_step;
16721 377 }
16722 757 break;
16723 case left:
16724
3/3
✓ Branch 0 taken 2098 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 45 times.
2183 switch(shiftdir)
16725 {
16726 case up:
16727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (!IsSideSwim()) dy = -step_diag;
16728
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (IsSideSwim())
16729 {
16730 dy = up_step;
16731 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16732 }
16733 40 break;
16734 case down:
16735 45 dy = step_diag;
16736
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if (IsSideSwim()) dy = down_step;
16737 45 break;
16738 }
16739
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 2117 times.
2183 if(walkable)
16740 {
16741 2117 dx = -step;
16742
1/2
✓ Branch 0 taken 2117 times.
✗ Branch 1 not taken.
2117 if (IsSideSwim()) dx = left_step;
16743 2117 }
16744 2183 break;
16745 case right:
16746
3/3
✓ Branch 0 taken 2830 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 96 times.
3118 switch(shiftdir)
16747 {
16748 case up:
16749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if (!IsSideSwim()) dy = -step_diag;
16750
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (IsSideSwim())
16751 {
16752 dy = up_step;
16753 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16754 }
16755 192 break;
16756 case down:
16757 96 dy = step_diag;
16758
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if (IsSideSwim()) dy = down_step;
16759 96 break;
16760 }
16761
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 2915 times.
3118 if(walkable)
16762 {
16763 2915 dx = step;
16764
1/2
✓ Branch 0 taken 2915 times.
✗ Branch 1 not taken.
2915 if (IsSideSwim()) dx = right_step;
16765 2915 }
16766 3118 break;
16767 };
16768 9740 }
16769 else
16770 {
16771 if(hero_newstep < step) step = hero_newstep; //handle collision
16772 switch(d2)
16773 {
16774 case up:
16775 dy -= step;
16776 if (IsSideSwim()) dy = up_step;
16777 break;
16778 case down:
16779 dy += step;
16780 if (IsSideSwim()) dy = down_step;
16781 break;
16782 case left:
16783 dx -= step;
16784 if (IsSideSwim()) dx = left_step;
16785 break;
16786 case right:
16787 dx += step;
16788 if (IsSideSwim()) dx = right_step;
16789 break;
16790 };
16791 }
16792 9740 hero_newstep = movepix;
16793 9740 hero_newstep_diag = movepix;
16794
16795
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 9740 times.
✓ Branch 2 taken 6732 times.
✓ Branch 3 taken 3008 times.
✓ Branch 4 taken 6732 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6732 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6732 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
9740 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
16796 {
16797 6732 dir=d2;
16798 6732 }
16799
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 3008 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3008 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
16800 {
16801 dir = shiftdir;
16802 }
16803
1/2
✓ Branch 0 taken 9740 times.
✗ Branch 1 not taken.
9740 if(forceRate > -1)
16804 {
16805 checkladder = false;
16806 switch(dir)
16807 {
16808 case right:
16809 case r_up:
16810 case r_down:
16811 dx = zfix(forceRate) / 100;
16812 break;
16813 case left:
16814 case l_up:
16815 case l_down:
16816 dx = zfix(-forceRate) / 100;
16817 break;
16818 default:
16819 dx = 0;
16820 }
16821 switch(dir)
16822 {
16823 case down:
16824 case r_down:
16825 case l_down:
16826 dy = zfix(forceRate) / 100;
16827 break;
16828 case up:
16829 case r_up:
16830 case l_up:
16831 dy = zfix(-forceRate) / 100;
16832 break;
16833 default:
16834 dy = 0;
16835 }
16836 }
16837
4/4
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 8504 times.
✓ Branch 2 taken 745 times.
✓ Branch 3 taken 491 times.
9740 if(dx == 0 && dy == 0) return;
16838
5/8
✓ Branch 0 taken 6241 times.
✓ Branch 1 taken 3008 times.
✓ Branch 2 taken 6241 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6241 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6241 times.
9249 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16839 {
16840 6241 herostep();
16841
16842 //ack... don't walk if in midair! -DD
16843
11/14
✓ Branch 0 taken 6241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6241 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6195 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 6195 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4526 times.
✓ Branch 9 taken 1669 times.
✓ Branch 10 taken 1270 times.
✓ Branch 11 taken 3256 times.
✓ Branch 12 taken 268 times.
✓ Branch 13 taken 1002 times.
6241 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
16844 {
16845 5193 action=walking; FFCore.setHeroAction(walking);
16846 5193 }
16847
16848
2/2
✓ Branch 0 taken 5911 times.
✓ Branch 1 taken 330 times.
6241 if(++hero_count > (16*hero_animation_speed))
16849 330 hero_count=0;
16850 6241 }
16851
1/2
✓ Branch 0 taken 3008 times.
✗ Branch 1 not taken.
3008 else if(!(frame & 1))
16852 {
16853 herostep();
16854 }
16855
16856
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9249 times.
✓ Branch 2 taken 3008 times.
✓ Branch 3 taken 3008 times.
9249 if(charging==0 || attack!=wHammer)
16857 {
16858 12257 sprite::move(dx, dy);
16859 12257 WalkflagInfo info;
16860 12257 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
16861 12257 execute(info);
16862
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6241 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6241 times.
✗ Branch 7 not taken.
12257 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
16863 {
16864 if (game->get_sideswim_jump() != 0)
16865 {
16866 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
16867 sfx(WAV_ZN1SPLASH,(int32_t)x);
16868 hopclk = 0;
16869 if (charging || spins) action = attacking;
16870 else action = none;
16871 }
16872 else
16873 {
16874 sprite::move(zfix(0), zfix(-1*dy));
16875 }
16876 }
16877 6241 }
16878 1168385 }
16879
16880 1158605 void HeroClass::moveOld(int32_t d2)
16881 {
16882 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
16883 static bool totalskip = false;
16884
16885
3/6
✓ Branch 0 taken 1158605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1158605 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1158605 times.
1158605 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16886 return;
16887
16888 1158605 int32_t dx=0,dy=0;
16889 1158605 int32_t xstep=lsteps[x.getInt()&7];
16890 1158605 int32_t ystep=lsteps[y.getInt()&7];
16891 1158605 int32_t z3skip=0;
16892 1158605 int32_t z3diagskip=0;
16893
3/6
✓ Branch 0 taken 27510 times.
✓ Branch 1 taken 1131095 times.
✓ Branch 2 taken 27510 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2289700 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
16894
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1131095 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1131095 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
16895
1/2
✓ Branch 0 taken 1158605 times.
✗ Branch 1 not taken.
1158605 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16896 1158605 bool is_swimming = (action == swimming);
16897
16898 //slow walk combo, or charging, moves at 2/3 speed
16899 if(
16900
4/4
✓ Branch 0 taken 1150655 times.
✓ Branch 1 taken 7950 times.
✓ Branch 2 taken 27510 times.
✓ Branch 3 taken 1123145 times.
1166555 (!is_swimming && (slowcharging ^ slowcombo))||
16901
2/2
✓ Branch 0 taken 7950 times.
✓ Branch 1 taken 1123145 times.
1131095 (is_swimming && (zinit.hero_swim_speed>60))
16902 )
16903 {
16904 35460 totalskip = false;
16905
16906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35460 times.
35460 if(diagonalMovement)
16907 {
16908 skipstep=(skipstep+1)%6;
16909
16910 if(skipstep%2==0) z3skip=1;
16911 else z3skip=0;
16912
16913 if(skipstep%3==0) z3diagskip=1;
16914 else z3diagskip=0;
16915 }
16916 else
16917 {
16918
2/2
✓ Branch 0 taken 26949 times.
✓ Branch 1 taken 8511 times.
35460 if(d2<left)
16919 {
16920
2/2
✓ Branch 0 taken 16226 times.
✓ Branch 1 taken 10723 times.
26949 if(ystep>1)
16921 {
16922 10723 skipstep^=1;
16923 10723 ystep=skipstep;
16924 10723 }
16925 26949 }
16926 else
16927 {
16928
2/2
✓ Branch 0 taken 5148 times.
✓ Branch 1 taken 3363 times.
8511 if(xstep>1)
16929 {
16930 3363 skipstep^=1;
16931 3363 xstep=skipstep;
16932 3363 }
16933 }
16934 }
16935 35460 }
16936 // else if(is_swimming || (slowcharging && slowcombo))
16937 else if(
16938
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1123145 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1123145 (is_swimming && (zinit.hero_swim_speed<60))||
16939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123145 times.
1123145 (slowcharging && slowcombo)
16940 )
16941 {
16942 //swimming, or charging on a slow combo, moves at 1/2 speed
16943 totalskip = !totalskip;
16944
16945 if(diagonalMovement)
16946 {
16947 skipstep=0;
16948 }
16949 }
16950 else
16951 {
16952 1123145 totalskip = false;
16953
16954
1/2
✓ Branch 0 taken 1123145 times.
✗ Branch 1 not taken.
1123145 if(diagonalMovement)
16955 {
16956 skipstep=0;
16957 }
16958 }
16959
16960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1158605 times.
1158605 if(!totalskip)
16961 {
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1158605 times.
1158605 if(diagonalMovement)
16963 {
16964 switch(d2)
16965 {
16966 case up:
16967 if(shiftdir==left)
16968 {
16969 if(walkable)
16970 {
16971 dy-=1-z3diagskip;
16972 dx-=1-z3diagskip;
16973 z3step=2;
16974 }
16975 else
16976 {
16977 dx-=1-z3diagskip;
16978 z3step=2;
16979 }
16980 }
16981 else if(shiftdir==right)
16982 {
16983 if(walkable)
16984 {
16985 dy-=1-z3diagskip;
16986 dx+=1-z3diagskip;
16987 z3step=2;
16988 }
16989 else
16990 {
16991 dx+=1-z3diagskip;
16992 z3step=2;
16993 }
16994 }
16995 else
16996 {
16997 if(walkable)
16998 {
16999 dy-=z3step-z3skip;
17000 z3step=(z3step%2)+1;
17001 }
17002 }
17003
17004 break;
17005
17006 case down:
17007 if(shiftdir==left)
17008 {
17009 if(walkable)
17010 {
17011 dy+=1-z3diagskip;
17012 dx-=1-z3diagskip;
17013 z3step=2;
17014 }
17015 else
17016 {
17017 dx-=1-z3diagskip;
17018 z3step=2;
17019 }
17020 }
17021 else if(shiftdir==right)
17022 {
17023 if(walkable)
17024 {
17025 dy+=1-z3diagskip;
17026 dx+=1-z3diagskip;
17027 z3step=2;
17028 }
17029 else
17030 {
17031 dx+=1-z3diagskip;
17032 z3step=2;
17033 }
17034 }
17035 else
17036 {
17037 if(walkable)
17038 {
17039 dy+=z3step-z3skip;
17040 z3step=(z3step%2)+1;
17041 }
17042 }
17043
17044 break;
17045
17046 case right:
17047 if(shiftdir==up)
17048 {
17049 if(walkable)
17050 {
17051 dy-=1-z3diagskip;
17052 dx+=1-z3diagskip;
17053 z3step=2;
17054 }
17055 else
17056 {
17057 dy-=1-z3diagskip;
17058 z3step=2;
17059 }
17060 }
17061 else if(shiftdir==down)
17062 {
17063 if(walkable)
17064 {
17065 dy+=1-z3diagskip;
17066 dx+=1-z3diagskip;
17067 z3step=2;
17068 }
17069 else
17070 {
17071 dy+=1-z3diagskip;
17072 z3step=2;
17073 }
17074 }
17075 else
17076 {
17077 if(walkable)
17078 {
17079 dx+=z3step-z3skip;
17080 z3step=(z3step%2)+1;
17081 }
17082 }
17083
17084 break;
17085
17086 case left:
17087 if(shiftdir==up)
17088 {
17089 if(walkable)
17090 {
17091 dy-=1-z3diagskip;
17092 dx-=1-z3diagskip;
17093 z3step=2;
17094 }
17095 else
17096 {
17097 dy-=1-z3diagskip;
17098 z3step=2;
17099 }
17100 }
17101 else if(shiftdir==down)
17102 {
17103 if(walkable)
17104 {
17105 dy+=1-z3diagskip;
17106 dx-=1-z3diagskip;
17107 z3step=2;
17108 }
17109 else
17110 {
17111 dy+=1-z3diagskip;
17112 z3step=2;
17113 }
17114 }
17115 else
17116 {
17117 if(walkable)
17118 {
17119 dx-=z3step-z3skip;
17120 z3step=(z3step%2)+1;
17121 }
17122 }
17123
17124 break;
17125 }
17126 }
17127 else
17128 {
17129
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 281341 times.
✓ Branch 2 taken 217301 times.
✓ Branch 3 taken 320257 times.
✓ Branch 4 taken 339706 times.
1158605 switch(d2)
17130 {
17131 case up:
17132
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 281341 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
281341 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
17133
17134 281341 break;
17135
17136 case down:
17137
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 217301 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
217301 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
17138
17139 217301 break;
17140
17141 case left:
17142 320257 dx-=xstep;
17143 320257 break;
17144
17145 case right:
17146 339706 dx+=xstep;
17147 339706 break;
17148 }
17149 }
17150 1158605 }
17151
17152
5/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1158605 times.
✓ Branch 2 taken 1158605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1158605 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1158605 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1158605 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1158605 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17153 {
17154 1158605 dir=d2;
17155 1158605 }
17156 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17157 {
17158 dir = shiftdir;
17159 }
17160
17161
3/4
✓ Branch 0 taken 1150655 times.
✓ Branch 1 taken 7950 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1150655 times.
1158605 if(action != swimming && !IsSideSwim())
17162 {
17163 1150655 herostep();
17164
17165 //ack... don't walk if in midair! -DD
17166
5/14
✓ Branch 0 taken 1150655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1150655 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1150655 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1150655 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1150655 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1150655 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17167 {
17168 1150655 action=walking; FFCore.setHeroAction(walking);
17169 1150655 }
17170
17171
2/2
✓ Branch 0 taken 1089473 times.
✓ Branch 1 taken 61182 times.
1150655 if(++hero_count > (16*hero_animation_speed))
17172 61182 hero_count=0;
17173 1150655 }
17174
2/2
✓ Branch 0 taken 3977 times.
✓ Branch 1 taken 3973 times.
7950 else if(!(frame & 1))
17175 {
17176 3973 herostep();
17177 3973 }
17178
17179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1158605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1158605 if(charging==0 || attack!=wHammer)
17180 {
17181 1158605 sprite::move((zfix)dx,(zfix)dy);
17182 1158605 }
17183 1158605 }
17184
17185 4519359 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
17186 {
17187 4519359 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
17188 }
17189 4519359 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
17190 {
17191 4519359 WalkflagInfo ret;
17192
17193 4519359 wx = vbound(wx, -1, 256);
17194 4519359 wy = vbound(wy, -1, 176);
17195
17196
7/8
✓ Branch 0 taken 4515147 times.
✓ Branch 1 taken 4212 times.
✓ Branch 2 taken 4510773 times.
✓ Branch 3 taken 4374 times.
✓ Branch 4 taken 4510773 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 473 times.
✓ Branch 7 taken 4510300 times.
4519359 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
17197 {
17198 9059 ret.setUnwalkable(false);
17199 9059 return ret;
17200 }
17201
17202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4510300 times.
4510300 if(toogam)
17203 {
17204 ret.setUnwalkable(false);
17205 return ret;
17206 }
17207
17208
4/4
✓ Branch 0 taken 76764 times.
✓ Branch 1 taken 4433536 times.
✓ Branch 2 taken 76478 times.
✓ Branch 3 taken 286 times.
4510300 if(blockpath && wy<(bigHitbox?80:88))
17209 {
17210 286 ret.setUnwalkable(true);
17211 286 return ret;
17212 }
17213
17214
4/4
✓ Branch 0 taken 26320 times.
✓ Branch 1 taken 4483694 times.
✓ Branch 2 taken 21126 times.
✓ Branch 3 taken 5194 times.
4510014 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
17215 {
17216 5194 ret.setUnwalkable(true);
17217 5194 return ret;
17218 }
17219
17220
2/2
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 4502376 times.
4504820 if (collide_object(wx, wy,1, 1))
17221 {
17222 2444 ret.setUnwalkable(true);
17223 2444 return ret;
17224 }
17225
17226
14/20
✓ Branch 0 taken 3482067 times.
✓ Branch 1 taken 1020309 times.
✓ Branch 2 taken 3318600 times.
✓ Branch 3 taken 163467 times.
✓ Branch 4 taken 3219442 times.
✓ Branch 5 taken 99158 times.
✓ Branch 6 taken 99158 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 99158 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 52968 times.
✓ Branch 13 taken 46190 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 46190 times.
✓ Branch 16 taken 46190 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5411 times.
✓ Branch 19 taken 4496965 times.
4565585 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17227
2/2
✓ Branch 0 taken 10241 times.
✓ Branch 1 taken 35949 times.
99158 && !get_bit(quest_rules,qr_FREEFORM))
17228 {
17229 5411 ret.setUnwalkable(true);
17230 5411 return ret;
17231 }
17232
17233
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4496965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4496965 times.
4496965 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
17234
17235
6/6
✓ Branch 0 taken 3476656 times.
✓ Branch 1 taken 1020309 times.
✓ Branch 2 taken 3313189 times.
✓ Branch 3 taken 163467 times.
✓ Branch 4 taken 1062673 times.
✓ Branch 5 taken 2250516 times.
4496965 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17236 {
17237
2/4
✓ Branch 0 taken 2250516 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2250516 times.
2250516 if((diagonalMovement||NO_GRIDLOCK))
17238 {
17239 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
17240
17241 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
17242 }
17243 2250516 }
17244 //All problems related to exiting water are probably here. -Z
17245
3/4
✓ Branch 0 taken 4449535 times.
✓ Branch 1 taken 47430 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4449535 times.
4496965 if(action==swimming || IsSideSwim())
17246 {
17247
2/2
✓ Branch 0 taken 46732 times.
✓ Branch 1 taken 698 times.
47430 if(!wf)
17248 {
17249 698 bool isthissolid = false;
17250
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 698 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 654 times.
742 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17251
4/6
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44 times.
698 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17252
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44 times.
44 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17253
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44 times.
698 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
17254 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17255
17256
17257
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 698 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 773 times.
1396 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
17258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 698 times.
698 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
17259 {
17260 //Check for out of bounds for swimming
17261 75 bool changehop = true;
17262
17263
4/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 75 times.
75 if((diagonalMovement||NO_GRIDLOCK))
17264 {
17265
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 if(wx<0||wy<0)
17266 changehop = false;
17267 else if(wx>248)
17268 changehop = false;
17269 else if(wx>240&&cnt==2)
17270 changehop = false;
17271 else if(wy>168)
17272 changehop = false;
17273 }
17274
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
75 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
17275 //This may be where the hang-up for exiting water exists. -Z
17276 // hop out of the water
17277
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 95 times.
115 if(changehop)
17278 95 ret.setHopClk(1);
17279 115 }
17280 else
17281 {
17282
6/6
✓ Branch 0 taken 603 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 429 times.
✓ Branch 3 taken 344 times.
✓ Branch 4 taken 344 times.
✓ Branch 5 taken 85 times.
773 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
17283 {
17284 //int32_t vx=((int32_t)x+4)&0xFFF8;
17285 //int32_t vy=((int32_t)y+4)&0xFFF8;
17286
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 219 times.
429 if(d2==left)
17287 {
17288
2/4
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
80 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
17289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
17290
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
40 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17291
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
40 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17292 {
17293 40 ret.setHopDir(d2);
17294 40 ret.setIlswim(true);
17295 40 }
17296 else ret.setIlswim(false);
17297 40 }
17298
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 47 times.
219 else if(d2==right)
17299 {
17300
4/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 144 times.
200 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
17301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
17302
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
28 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17303
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
28 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17304 {
17305 28 ret.setHopDir(d2);
17306 28 ret.setIlswim(true);
17307 28 }
17308 144 else ret.setIlswim(false);
17309 172 }
17310
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2 times.
47 else if(d2==up)
17311 {
17312
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
4 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
17313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
17314
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17315
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17316 {
17317 2 ret.setHopDir(d2);
17318 2 ret.setIlswim(true);
17319 2 }
17320 else ret.setIlswim(false);
17321 2 }
17322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 else if(d2==down)
17323 {
17324
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 36 times.
54 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
17325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
17326
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
17327
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
17328 {
17329 9 ret.setHopDir(d2);
17330 9 ret.setIlswim(true);
17331 9 }
17332 36 else ret.setIlswim(false);
17333 45 }
17334 259 }
17335
17336
2/4
✓ Branch 0 taken 603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 603 times.
603 if(wx<0||wy<0);
17337
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 243 times.
603 else if(wx>248);
17338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
243 else if(wx>240&&cnt==2);
17339
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 207 times.
243 else if(wy>168);
17340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
207 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17341 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
17342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17343 {
17344 ret.setUnwalkable(false);
17345 return ret;
17346 }
17347 else
17348 {
17349 207 ret.setUnwalkable(true);
17350 207 return ret;
17351 }
17352 }
17353 511 }
17354 else
17355 {
17356 46732 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17357 46732 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
17358
17359
8/8
✓ Branch 0 taken 44312 times.
✓ Branch 1 taken 2420 times.
✓ Branch 2 taken 43948 times.
✓ Branch 3 taken 364 times.
✓ Branch 4 taken 2420 times.
✓ Branch 5 taken 364 times.
✓ Branch 6 taken 2123 times.
✓ Branch 7 taken 297 times.
46732 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17360 {
17361 46071 ret.setUnwalkable(false);
17362 46071 return ret;
17363 }
17364 }
17365 1172 }
17366
2/2
✓ Branch 0 taken 101215 times.
✓ Branch 1 taken 4348320 times.
4449535 else if(ladderx+laddery) // ladder is being used
17367 {
17368
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 101215 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
101215 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
17369
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 101215 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
101215 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
17370
17371
2/4
✓ Branch 0 taken 101215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 101215 times.
101215 if((diagonalMovement||NO_GRIDLOCK))
17372 {
17373 if(ladderdir==up)
17374 {
17375 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17376 {
17377 bool temp = false;
17378
17379 if(!(abs(lx-(ladderx+8))<=8))
17380 temp = true;
17381
17382 if(cnt==2)
17383 if(!(abs((lx+8)-(ladderx+8))<=8))
17384 temp=true;
17385
17386 if(!temp)
17387 {
17388 ret.setUnwalkable(false);
17389 return ret;
17390 }
17391
17392 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17393 {
17394 ret.setUnwalkable(true);
17395 return ret;
17396 }
17397 }
17398 }
17399 else
17400 {
17401 if(abs(lx-(ladderx+8))<=8)
17402 {
17403 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17404 {
17405 ret.setUnwalkable(false);
17406 return ret;
17407 }
17408
17409 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17410 {
17411 ret.setUnwalkable(true);
17412 return ret;
17413 }
17414
17415 if((abs(ly-laddery+8)<=8) && d2<=down)
17416 {
17417 ret.setUnwalkable(false);
17418 return ret;
17419 }
17420 }
17421 }
17422 } // diagonalMovement
17423 else
17424 {
17425
2/2
✓ Branch 0 taken 63306 times.
✓ Branch 1 taken 37909 times.
101215 if((d2&2)==ladderdir) // same direction
17426 {
17427
3/3
✓ Branch 0 taken 3195 times.
✓ Branch 1 taken 56947 times.
✓ Branch 2 taken 3164 times.
63306 switch(d2)
17428 {
17429 case up:
17430
2/2
✓ Branch 0 taken 2104 times.
✓ Branch 1 taken 1060 times.
3164 if(y.getInt()<=laddery)
17431 {
17432
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2104 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 2040 times.
4144 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
17433
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2040 times.
2040 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
17434 2104 return ret;
17435
17436 }
17437
17438 [[fallthrough]];
17439 case down:
17440
2/2
✓ Branch 0 taken 2317 times.
✓ Branch 1 taken 1938 times.
4255 if((wy&0xF0)==laddery)
17441 {
17442 2317 ret.setUnwalkable(false);
17443 2317 return ret;
17444 }
17445
17446 1938 break;
17447
17448 default:
17449
2/2
✓ Branch 0 taken 23305 times.
✓ Branch 1 taken 33642 times.
56947 if((wx&0xF0)==ladderx)
17450 {
17451 23305 ret.setUnwalkable(false);
17452 23305 return ret;
17453 }
17454 33642 }
17455
17456
2/2
✓ Branch 0 taken 1938 times.
✓ Branch 1 taken 33642 times.
35580 if(d2<=down)
17457 {
17458
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1938 times.
✓ Branch 2 taken 1938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 1923 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1923 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1923 times.
1938 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
17459 1938 return ret;
17460 }
17461
17462
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 33642 times.
✓ Branch 2 taken 33642 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4414 times.
✓ Branch 5 taken 29228 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 29228 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 29228 times.
33642 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
17463 33642 return ret;
17464 }
17465
17466 // different dir
17467
2/8
✓ Branch 0 taken 37909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37909 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
37909 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
17468 {
17469 37909 ret.setUnwalkable(true);
17470 37909 return ret;
17471 }
17472
17473 if(wy>=laddery && wy<=laddery+16 && d2<=down)
17474 {
17475 ret.setUnwalkable(false);
17476 return ret;
17477 }
17478 }
17479 }
17480
6/6
✓ Branch 0 taken 3865612 times.
✓ Branch 1 taken 482708 times.
✓ Branch 2 taken 3847832 times.
✓ Branch 3 taken 17780 times.
✓ Branch 4 taken 7127 times.
✓ Branch 5 taken 3840705 times.
4348320 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17481 {
17482 // see if it's a good spot for the ladder or for swimming
17483
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 507615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 507615 times.
507615 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17484
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 507615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 507615 times.
507615 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
17485
17486
2/2
✓ Branch 0 taken 25283 times.
✓ Branch 1 taken 482332 times.
507615 if(get_bit(quest_rules, qr_DROWN))
17487 {
17488 // Drowning changes the following attributes:
17489 // * Dangerous water is also walkable, so ignore the previous
17490 // definitions of unwalkablex and unwalkablex8.
17491 // * Instead, prevent the ladder from being used in the
17492 // one frame where Hero has landed on water before drowning.
17493 25283 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17494 25283 }
17495
17496 // check if he can swim
17497
4/6
✓ Branch 0 taken 28895 times.
✓ Branch 1 taken 478720 times.
✓ Branch 2 taken 28895 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28895 times.
507615 if(current_item(itype_flippers) && z==0 && fakez==0)
17498 {
17499 28895 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17500 28895 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
17501
2/6
✓ Branch 0 taken 28895 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28895 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17502 {
17503 //ladder ignores water combos that are now walkable thanks to flippers -DD
17504
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 28697 times.
28895 unwalkablex = unwalkablex && (!wtrx);
17505
2/2
✓ Branch 0 taken 27409 times.
✓ Branch 1 taken 1486 times.
28895 unwalkablex8 = unwalkablex8 && (!wtrx8);
17506
17507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28895 times.
28895 if(landswim >= 22)
17508 {
17509 ret.setHopClk(2);
17510 ret.setUnwalkable(false);
17511 return ret;
17512 }
17513
8/8
✓ Branch 0 taken 27216 times.
✓ Branch 1 taken 1679 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 26774 times.
✓ Branch 4 taken 1679 times.
✓ Branch 5 taken 26774 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1667 times.
28895 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17514 {
17515
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
454 if(!(diagonalMovement||NO_GRIDLOCK))
17516 {
17517 454 ret.setHopClk(2);
17518
17519
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
454 if(charging || spins>5)
17520 {
17521 //if Hero is charging, he might be facing the wrong direction (we want him to
17522 //hop into the water, not in the facing direction)
17523 ret.setDir(d2);
17524 //moreover Hero can't charge in the water -DD
17525 ret.setChargeAttack();
17526 }
17527
17528 454 ret.setUnwalkable(false);
17529 454 return ret;
17530 }
17531 else if(dir==d2)
17532 {
17533 ret.setIlswim(true);
17534 ladderx = 0;
17535 laddery = 0;
17536 }
17537 }
17538 28441 }
17539 28441 }
17540
17541 // check if he can use the ladder
17542 // "Allow Ladder Anywhere" is toggled by fLADDER
17543
2/2
✓ Branch 0 taken 211037 times.
✓ Branch 1 taken 296124 times.
507161 if(can_deploy_ladder())
17544 // laddersetup
17545 {
17546 // Check if there's water to use the ladder over
17547 296124 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
17548 296124 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
17549 296124 int32_t ldrid = current_item_id(itype_ladder);
17550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296124 times.
296124 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17551
17552
4/4
✓ Branch 0 taken 291351 times.
✓ Branch 1 taken 4773 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 291337 times.
296124 if(wtrx || wtrx8)
17553 {
17554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4787 times.
4787 if(isSideViewHero())
17555 {
17556 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17557 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17558 }
17559 // * walk on half-water using the ladder instead of using flippers.
17560 // * otherwise, walk on ladder(+hookshot) combos.
17561
3/8
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 4504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 283 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4787 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
17562 {
17563
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17564 {
17565 //if Hero could swim on a tile instead of using the ladder,
17566 //refuse to use the ladder to step over that tile. -DD
17567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
283 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
17568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
283 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
17569 283 }
17570 283 }
17571 4787 }
17572 else
17573 {
17574 // No water; check other things
17575
17576 //Check pits
17577
1/2
✓ Branch 0 taken 291337 times.
✗ Branch 1 not taken.
291337 if(ladderpits)
17578 {
17579 int32_t pit_cmb = getpitfall(wx,wy);
17580 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17581 pit_cmb = getpitfall(x+8,wy);
17582 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17583 }
17584
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 291337 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
291337 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17585 {
17586 291337 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
17587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291337 times.
291337 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17588 291337 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
17589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291337 times.
291337 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17590 291337 }
17591 }
17592
17593
2/2
✓ Branch 0 taken 592248 times.
✓ Branch 1 taken 296124 times.
888372 for (int32_t i = 0; i <= 1; ++i)
17594 {
17595
2/2
✓ Branch 0 taken 505688 times.
✓ Branch 1 taken 86560 times.
592248 if(tmpscr2[i].valid!=0)
17596 {
17597
1/2
✓ Branch 0 taken 86560 times.
✗ Branch 1 not taken.
86560 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17598 {
17599
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 86560 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
86560 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17600
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 86560 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
86560 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17601 86560 }
17602 else
17603 {
17604 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17605 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17606 }
17607 86560 }
17608 592248 }
17609
1/2
✓ Branch 0 taken 296124 times.
✗ Branch 1 not taken.
296124 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
17610
17611
2/4
✓ Branch 0 taken 296124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 296124 times.
296124 if((diagonalMovement||NO_GRIDLOCK))
17612 {
17613 if(d2==dir)
17614 {
17615 int32_t c = walkwater ? 0:8;
17616 int32_t b = walkwater ? 8:0;
17617
17618 if(d2>=left)
17619 {
17620 // If the difference between wy and y is small enough
17621 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
17622 {
17623 // Don't activate the ladder if it would be entirely
17624 // over water and Hero has the flippers. This isn't
17625 // a good way to do this, but it's too risky
17626 // to make big changes to this stuff.
17627 bool deployLadder=true;
17628 int32_t lx=wx&0xF0;
17629 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17630 {
17631 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17632 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17633 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17634 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17635 deployLadder=false;
17636 }
17637 if(deployLadder)
17638 {
17639 ladderx = wx&0xF0;
17640 laddery = y;
17641 ladderdir = left;
17642 ladderstart = d2;
17643 ret.setUnwalkable(laddery!=y.getInt());
17644 return ret;
17645 }
17646 }
17647 }
17648 else if(d2<=down)
17649 {
17650 // If the difference between wx and x is small enough
17651 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
17652 {
17653 ladderx = x;
17654 laddery = wy&0xF0;
17655 ladderdir = up;
17656 ladderstart = d2;
17657 ret.setUnwalkable(ladderx!=x.getInt());
17658 return ret;
17659 }
17660
17661 if(cnt==2)
17662 {
17663 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17664 {
17665 ladderx = x;
17666 laddery = wy&0xF0;
17667 ladderdir = up;
17668 ladderstart = d2;
17669 ret.setUnwalkable(ladderx!=x.getInt());
17670 return ret;
17671 }
17672 }
17673 }
17674 }
17675 }
17676 else
17677 {
17678
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 296124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 296124 times.
✓ Branch 4 taken 2905 times.
✓ Branch 5 taken 293219 times.
296124 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
17679
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 296124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 296124 times.
✓ Branch 4 taken 274832 times.
✓ Branch 5 taken 21292 times.
296124 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
17680
17681
2/2
✓ Branch 0 taken 272207 times.
✓ Branch 1 taken 23917 times.
296138 if((d2>=left && wtrx)
17682 // Deploy the ladder vertically even if Hero is only half on water.
17683
8/8
✓ Branch 0 taken 5411 times.
✓ Branch 1 taken 266796 times.
✓ Branch 2 taken 23917 times.
✓ Branch 3 taken 266796 times.
✓ Branch 4 taken 334 times.
✓ Branch 5 taken 23583 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 23903 times.
296124 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
17684 {
17685
4/4
✓ Branch 0 taken 5290 times.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 227 times.
✓ Branch 3 taken 5063 times.
5411 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
17686 348 ladderdir = up;
17687 else
17688 5063 ladderdir = left;
17689
17690
2/2
✓ Branch 0 taken 5063 times.
✓ Branch 1 taken 348 times.
5411 if(ladderdir==up)
17691 {
17692 348 ladderx = x.getInt()&0xF8;
17693 348 laddery = wy&0xF0;
17694 348 }
17695 else
17696 {
17697 5063 ladderx = wx&0xF0;
17698 5063 laddery = y.getInt()&0xF8;
17699 }
17700
17701 5411 ret.setUnwalkable(false);
17702 5411 return ret;
17703 }
17704 }
17705 290713 }
17706 501750 }
17707
17708 4343627 ret.setUnwalkable(wf);
17709 4343627 return ret;
17710 4519379 }
17711
17712 // Only checks for moving blocks. Apparently this is a thing we need.
17713 516424 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
17714 {
17715 516424 HeroClass::WalkflagInfo ret;
17716
2/2
✓ Branch 0 taken 3670 times.
✓ Branch 1 taken 512754 times.
516424 if (!blockmoving) //Without this, weird swimming behaviors happen.
17717 {
17718 512754 ret.setFlags(~1);
17719 512754 ret.setHopDir(-1);
17720 512754 }
17721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516424 times.
516424 if(toogam) return ret;
17722
2/2
✓ Branch 0 taken 512754 times.
✓ Branch 1 taken 3670 times.
516424 if (blockmoving)
17723 3670 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
17724
2/2
✓ Branch 0 taken 516236 times.
✓ Branch 1 taken 188 times.
516424 if (collide_object(wx, wy,1, 1))
17725 188 ret.setUnwalkable(true);
17726 516424 return ret;
17727 516424 }
17728
17729 1978014 bool HeroClass::checksoliddamage()
17730 {
17731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1978014 times.
1978014 if(toogam) return false;
17732
17733
2/4
✓ Branch 0 taken 1978014 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1978014 times.
1978014 if(z!=0||fakez!=0) return false;
17734 1978014 int32_t bx = x.getInt();
17735 1978014 int32_t by = y.getInt();
17736 1978014 int32_t initk = 0;
17737
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 487793 times.
✓ Branch 2 taken 386035 times.
✓ Branch 3 taken 541921 times.
✓ Branch 4 taken 562265 times.
1978014 switch(dir)
17738 {
17739 case up:
17740
17741 487793 by-=bigHitbox ? 4 : -4;
17742
17743
1/2
✓ Branch 0 taken 487793 times.
✗ Branch 1 not taken.
487793 if(by<0)
17744 {
17745 return false;
17746 }
17747 487793 break;
17748
17749 case down:
17750
17751 386035 by+=20;
17752
2/2
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 383883 times.
386035 if(by>175)
17753 {
17754 2152 return false;
17755 }
17756
17757 383883 break;
17758
17759 case left:
17760 541921 bx-=4;
17761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 541921 times.
541921 if (!bigHitbox)
17762 {
17763 541921 by+=8;
17764 541921 initk = 1;
17765 541921 }
17766
2/2
✓ Branch 0 taken 539953 times.
✓ Branch 1 taken 1968 times.
541921 if(bx<0)
17767 {
17768 1968 return false;
17769 }
17770
17771 539953 break;
17772
17773 case right:
17774
17775 562265 bx+=20;
17776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562265 times.
562265 if (!bigHitbox)
17777 {
17778 562265 by+=8;
17779 562265 initk = 1;
17780 562265 }
17781
2/2
✓ Branch 0 taken 3032 times.
✓ Branch 1 taken 559233 times.
562265 if(bx>255)
17782 {
17783 3032 return false;
17784 }
17785
17786 559233 break;
17787 }
17788 1970862 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
17789 1970862 int32_t t = cmb.type;
17790
1/2
✓ Branch 0 taken 1970862 times.
✗ Branch 1 not taken.
1970862 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17791 t = cNONE;
17792 1970862 int32_t initbx = bx;
17793 1970862 int32_t initby = by;
17794
17795 // Unlike push blocks, damage combos should be tested on layers 2 and under
17796
2/2
✓ Branch 0 taken 3107724 times.
✓ Branch 1 taken 1970861 times.
5078585 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
17797 {
17798 3107724 bx = initbx;
17799 3107724 by = initby;
17800
2/2
✓ Branch 0 taken 7626459 times.
✓ Branch 1 taken 3107723 times.
10734182 for (int32_t k = initk; k <= 2; k++)
17801 {
17802 7626459 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
17803 7626459 t = cmb.type;
17804
1/2
✓ Branch 0 taken 7626459 times.
✗ Branch 1 not taken.
7626459 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17805 t = cNONE;
17806 // Solid damage combos use pushing>0, hence the code is here.
17807
10/10
✓ Branch 0 taken 48694 times.
✓ Branch 1 taken 7577765 times.
✓ Branch 2 taken 25759 times.
✓ Branch 3 taken 22935 times.
✓ Branch 4 taken 24697 times.
✓ Branch 5 taken 1062 times.
✓ Branch 6 taken 2736 times.
✓ Branch 7 taken 21961 times.
✓ Branch 8 taken 81 times.
✓ Branch 9 taken 2655 times.
7626459 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
17808 {
17809
8/18
✓ Branch 0 taken 7621010 times.
✓ Branch 1 taken 1732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1732 times.
✓ Branch 4 taken 1732 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 1708 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 24 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 7622742 times.
✗ Branch 17 not taken.
7622742 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
17810 {
17811 // Bite Hero
17812 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
17813 }
17814 7622742 }
17815
3/4
✓ Branch 0 taken 25759 times.
✓ Branch 1 taken 7600700 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25249 times.
7651708 if(isSideViewHero() && // Check for sideview damage combos
17816
3/4
✓ Branch 0 taken 25249 times.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 25249 times.
✗ Branch 3 not taken.
25759 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
17817 {
17818
1/2
✓ Branch 0 taken 25249 times.
✗ Branch 1 not taken.
25249 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
17819 {
17820
5/6
✓ Branch 0 taken 25249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 25018 times.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 159 times.
25249 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
17821 {
17822
4/4
✓ Branch 0 taken 25083 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 25089 times.
✓ Branch 3 taken 1 times.
25090 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
17823 {
17824
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
17825 }
17826 25089 }
17827
1/2
✓ Branch 0 taken 25248 times.
✗ Branch 1 not taken.
25248 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
17828 25248 }
17829 else
17830 {
17831 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
17832 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
17833 {
17834 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
17835 x+8+(zc_max(tmpscr->csensitive-1,0)),
17836 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
17837 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
17838 return true;
17839 }
17840 else //2.50.1 and later
17841 {
17842 if(checkdamagecombos(x+4, x+12, y+16, y+24))
17843 return true;
17844 }
17845 }
17846
17847 25248 }
17848
2/2
✓ Branch 0 taken 4233036 times.
✓ Branch 1 taken 3393422 times.
7626458 if (dir < left) bx += (k % 2) ? 7 : 8;
17849 3393422 else by += (k % 2) ? 7 : 8;
17850 7626458 }
17851 3107723 }
17852 1970861 return false;
17853 1978014 }
17854 1980088 void HeroClass::checkpushblock()
17855 {
17856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980088 times.
1980088 if(toogam) return;
17857
17858
3/4
✓ Branch 0 taken 1979968 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979968 times.
1980088 if(z!=0||fakez!=0) return;
17859
17860 // Return early in some cases..
17861 1979968 bool earlyReturn=false;
17862
17863
4/4
✓ Branch 0 taken 1970739 times.
✓ Branch 1 taken 9229 times.
✓ Branch 2 taken 1973534 times.
✓ Branch 3 taken 6434 times.
1979968 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
17864
2/2
✓ Branch 0 taken 669598 times.
✓ Branch 1 taken 1303936 times.
1973534 if(x.getInt()&15) earlyReturn=true;
17865
17866 // if(y<16) return;
17867
4/4
✓ Branch 0 taken 6082 times.
✓ Branch 1 taken 1973886 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 1954 times.
1979968 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
17868
17869 1978014 int32_t bx = x.getInt()&0xF0;
17870 1978014 int32_t by = (y.getInt()&0xF0);
17871
17872
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 487793 times.
✓ Branch 2 taken 386035 times.
✓ Branch 3 taken 541921 times.
✓ Branch 4 taken 562265 times.
1978014 switch(dir)
17873 {
17874 case up:
17875
2/2
✓ Branch 0 taken 13708 times.
✓ Branch 1 taken 474085 times.
487793 if(y<16)
17876 {
17877 13708 earlyReturn=true;
17878 13708 break;
17879 }
17880
17881
3/4
✓ Branch 0 taken 68049 times.
✓ Branch 1 taken 406036 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68049 times.
474085 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
17882
17883
2/2
✓ Branch 0 taken 266051 times.
✓ Branch 1 taken 208034 times.
474085 if((int32_t)x&8) bx+=16;
17884
17885 474085 break;
17886
17887 case down:
17888
2/2
✓ Branch 0 taken 13989 times.
✓ Branch 1 taken 372046 times.
386035 if(y>128)
17889 {
17890 13989 earlyReturn=true;
17891 13989 break;
17892 }
17893 else
17894 {
17895 372046 by+=16;
17896
17897
2/2
✓ Branch 0 taken 228132 times.
✓ Branch 1 taken 143914 times.
372046 if((int32_t)x&8) bx+=16;
17898 }
17899
17900 372046 break;
17901
17902 case left:
17903
2/2
✓ Branch 0 taken 17900 times.
✓ Branch 1 taken 524021 times.
541921 if(x<32)
17904 {
17905 17900 earlyReturn=true;
17906 17900 break;
17907 }
17908 else
17909 {
17910 524021 bx-=16;
17911
17912
2/2
✓ Branch 0 taken 316053 times.
✓ Branch 1 taken 207968 times.
524021 if(y.getInt()&8)
17913 {
17914 207968 by+=16;
17915 207968 }
17916 }
17917
17918 524021 break;
17919
17920 case right:
17921
2/2
✓ Branch 0 taken 19681 times.
✓ Branch 1 taken 542584 times.
562265 if(x>208)
17922 {
17923 19681 earlyReturn=true;
17924 19681 break;
17925 }
17926 else
17927 {
17928 542584 bx+=16;
17929
17930
2/2
✓ Branch 0 taken 336075 times.
✓ Branch 1 taken 206509 times.
542584 if(y.getInt()&8)
17931 {
17932 206509 by+=16;
17933 206509 }
17934 }
17935
17936 542584 break;
17937 }
17938
17939
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1978013 times.
1978014 if (checksoliddamage()) return;
17940
17941
2/2
✓ Branch 0 taken 1318262 times.
✓ Branch 1 taken 659751 times.
1978013 if(earlyReturn)
17942 1318262 return;
17943
17944 659751 int32_t itemid=current_item_id(itype_bracelet);
17945 659751 size_t combopos = (by&0xF0)+(bx>>4);
17946
2/2
✓ Branch 0 taken 193400 times.
✓ Branch 1 taken 466351 times.
659751 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
17947
2/2
✓ Branch 0 taken 466351 times.
✓ Branch 1 taken 193400 times.
659751 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
17948
2/2
✓ Branch 0 taken 463466 times.
✓ Branch 1 taken 1585297 times.
2048763 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
17949 {
17950
4/4
✓ Branch 0 taken 243587 times.
✓ Branch 1 taken 1341710 times.
✓ Branch 2 taken 46920 times.
✓ Branch 3 taken 196667 times.
1585297 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
17951
4/4
✓ Branch 0 taken 926168 times.
✓ Branch 1 taken 462462 times.
✓ Branch 2 taken 924982 times.
✓ Branch 3 taken 1186 times.
1388630 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
17952 924982 continue;
17953 463648 mapscr* m = FFCore.tempScreens[lyr];
17954 463648 int32_t f = MAPFLAG2(lyr-1,bx,by);
17955 463648 int32_t f2 = MAPCOMBOFLAG2(lyr-1,bx,by);
17956 463648 int32_t t = combobuf[MAPCOMBOL(lyr,bx,by)].type;
17957
2/2
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 463084 times.
463648 if (lyr == 0) t = combobuf[MAPCOMBO(bx,by)].type;
17958
17959
8/8
✓ Branch 0 taken 437324 times.
✓ Branch 1 taken 25196 times.
✓ Branch 2 taken 436193 times.
✓ Branch 3 taken 1131 times.
✓ Branch 4 taken 2974 times.
✓ Branch 5 taken 409154 times.
✓ Branch 6 taken 435306 times.
✓ Branch 7 taken 438280 times.
463648 if((t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) && (pushing<16 || hasMainGuy())) continue;
17960
17961
8/8
✓ Branch 0 taken 437866 times.
✓ Branch 1 taken 414 times.
✓ Branch 2 taken 436421 times.
✓ Branch 3 taken 1445 times.
✓ Branch 4 taken 436412 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 409 times.
✓ Branch 7 taken 438495 times.
440046 if((t==cPUSH_HW || t==cPUSH_HEAVY || t==cPUSH_HEAVY2 || t==cPUSH_HW2)
17962
8/8
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 437138 times.
✓ Branch 2 taken 1366 times.
✓ Branch 3 taken 400 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1357 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 1357 times.
439637 && (itemid<0 || glove->power<((t==cPUSH_HEAVY2 || t==cPUSH_HW2)?2:1) ||
17963
1/4
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1766 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
17964
17965 438495 bool doit=false;
17966 438495 bool changeflag=false;
17967 438495 bool changecombo=false;
17968
17969
7/8
✓ Branch 0 taken 437622 times.
✓ Branch 1 taken 873 times.
✓ Branch 2 taken 437622 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 435 times.
✓ Branch 5 taken 438060 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 437245 times.
875766 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
17970
3/4
✓ Branch 0 taken 437648 times.
✓ Branch 1 taken 412 times.
✓ Branch 2 taken 437648 times.
✗ Branch 3 not taken.
438060 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
17971
3/4
✓ Branch 0 taken 437669 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 437669 times.
✗ Branch 3 not taken.
438060 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
17972
3/4
✓ Branch 0 taken 437668 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 437668 times.
✗ Branch 3 not taken.
438060 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
17973
3/4
✓ Branch 0 taken 437641 times.
✓ Branch 1 taken 419 times.
✓ Branch 2 taken 437641 times.
✗ Branch 3 not taken.
438060 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
17974
3/4
✓ Branch 0 taken 437667 times.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 437667 times.
✗ Branch 3 not taken.
438060 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
17975
2/2
✓ Branch 0 taken 437271 times.
✓ Branch 1 taken 3 times.
437274 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
17976 {
17977 464 changeflag=true;
17978 464 doit=true;
17979 464 }
17980
17981
4/8
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 437709 times.
✓ Branch 6 taken 437709 times.
✗ Branch 7 not taken.
875418 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
17982
2/4
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437709 times.
✗ Branch 3 not taken.
437709 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
17983
2/4
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437709 times.
✗ Branch 3 not taken.
437709 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
17984
2/4
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437709 times.
✗ Branch 3 not taken.
437709 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
17985
2/4
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437709 times.
✗ Branch 3 not taken.
437709 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
17986
2/4
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437709 times.
✗ Branch 3 not taken.
437709 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
17987
1/2
✓ Branch 0 taken 437709 times.
✗ Branch 1 not taken.
437709 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
17988 {
17989 changecombo=true;
17990 doit=true;
17991 }
17992
17993
2/2
✓ Branch 0 taken 14382 times.
✓ Branch 1 taken 423327 times.
437709 if(get_bit(quest_rules,qr_SOLIDBLK))
17994 {
17995
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
✓ Branch 2 taken 2869 times.
✓ Branch 3 taken 3303 times.
✓ Branch 4 taken 5288 times.
14382 switch(dir)
17996 {
17997 case up:
17998
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2922 times.
✓ Branch 4 taken 1749 times.
✓ Branch 5 taken 1173 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1173 times.
✓ Branch 8 taken 1749 times.
✓ Branch 9 taken 1173 times.
2922 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
17999
18000 2922 break;
18001
18002 case down:
18003
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2869 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2869 times.
✓ Branch 4 taken 1561 times.
✓ Branch 5 taken 1308 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1308 times.
✓ Branch 8 taken 1561 times.
✓ Branch 9 taken 1308 times.
2869 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
18004
18005 2869 break;
18006
18007 case left:
18008
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3303 times.
✓ Branch 4 taken 1158 times.
✓ Branch 5 taken 2145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2145 times.
✓ Branch 8 taken 1158 times.
✓ Branch 9 taken 2145 times.
3303 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
18009
18010 3303 break;
18011
18012 case right:
18013
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 1675 times.
✓ Branch 5 taken 3613 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3613 times.
✓ Branch 8 taken 1675 times.
✓ Branch 9 taken 3613 times.
5288 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
18014
18015 5288 break;
18016 }
18017 14382 }
18018
18019
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 181884 times.
✓ Branch 2 taken 152567 times.
✓ Branch 3 taken 50405 times.
✓ Branch 4 taken 52853 times.
437709 switch(dir)
18020 {
18021 case up:
18022
3/4
✓ Branch 0 taken 181842 times.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 181842 times.
181884 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
18023
18024 181884 break;
18025
18026 case down:
18027
3/4
✓ Branch 0 taken 152330 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 152330 times.
152567 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
18028
18029 152567 break;
18030
18031 case left:
18032
3/4
✓ Branch 0 taken 50370 times.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50370 times.
50405 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
18033
18034 50405 break;
18035
18036 case right:
18037
3/4
✓ Branch 0 taken 52851 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52851 times.
52853 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
18038
18039 52853 break;
18040 }
18041
18042
2/2
✓ Branch 0 taken 437469 times.
✓ Branch 1 taken 240 times.
437709 if(doit)
18043 {
18044
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(limitedpush)
18045 ++usecounts[itemid];
18046
18047 // for(int32_t i=0; i<1; i++)
18048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
240 if(!blockmoving)
18049 {
18050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
240 if(changeflag)
18051 {
18052 240 m->sflag[combopos]=0;
18053 240 }
18054
18055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
240 if(mblock2.clk<=0)
18056 {
18057 240 mblock2.blockLayer = lyr;
18058 240 mblock2.push((zfix)bx,(zfix)by,dir,f);
18059
18060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
240 if(get_bit(quest_rules,qr_MORESOUNDS))
18061 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
18062 240 }
18063 240 }
18064 240 break;
18065 }
18066 437469 }
18067 1980710 }
18068
18069 98 bool usekey()
18070 {
18071 98 int32_t itemid = current_item_id(itype_magickey);
18072
18073
3/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
98 if(itemid<0 ||
18074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18075 : itemsbuf[itemid].power!=dlevel))
18076 {
18077
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 53 times.
78 if(game->lvlkeys[dlevel]!=0)
18078 {
18079 25 game->lvlkeys[dlevel]--;
18080 //run script for level key item
18081 25 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
18082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2125 times.
2125 for ( int32_t q = 0; q < MAXITEMS; ++q )
18083 {
18084
2/2
✓ Branch 0 taken 2100 times.
✓ Branch 1 taken 25 times.
2125 if ( itemsbuf[q].family == itype_lkey )
18085 {
18086 25 key_item = q; break;
18087 }
18088 2100 }
18089
18090
2/8
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18091 {
18092 ri = &(itemScriptData[key_item]);
18093 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18094 ri->Clear();
18095 item_doscript[key_item] = 1;
18096 itemscriptInitialised[key_item] = 0;
18097 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18098 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18099 }
18100 25 return true;
18101 }
18102 else
18103 {
18104
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 50 times.
53 if(game->get_keys()==0)
18105 {
18106 3 return false;
18107 }
18108 else
18109 {
18110 //run script for key item
18111 50 int32_t key_item = 0; //current_item_id(itype_key); //not possible
18112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 for ( int32_t q = 0; q < MAXITEMS; ++q )
18113 {
18114
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 50 times.
500 if ( itemsbuf[q].family == itype_key )
18115 {
18116 50 key_item = q; break;
18117 }
18118 450 }
18119 //zprint2("key_item is: %d\n",key_item);
18120 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
18121
2/8
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18122 {
18123 ri = &(itemScriptData[key_item]);
18124 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18125 ri->Clear();
18126 item_doscript[key_item] = 1;
18127 itemscriptInitialised[key_item] = 0;
18128 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18129 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18130 }
18131 50 game->change_keys(-1);
18132 }
18133 }
18134 50 }
18135
18136 70 return true;
18137 98 }
18138
18139 bool canUseKey(int32_t num)
18140 {
18141 int32_t itemid = current_item_id(itype_magickey);
18142
18143 if(itemid<0 ||
18144 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18145 : itemsbuf[itemid].power!=dlevel))
18146 {
18147 return game->lvlkeys[dlevel] + game->get_keys() >= num;
18148 }
18149
18150 return true;
18151 }
18152
18153 bool usekey(int32_t num)
18154 {
18155 if(!canUseKey(num)) return false;
18156 for(auto q = 0; q < num; ++q)
18157 {
18158 if(!usekey()) return false; //should never return false here, but, just to be safe....
18159 }
18160 return true;
18161 }
18162
18163
18164 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
18165 {
18166 int32_t mc = (y&0xF0)+(x>>4);
18167 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
18168 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
18169 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
18170 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
18171 return ret;
18172 }
18173
18174 1970739 void HeroClass::oldchecklockblock()
18175 {
18176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970739 times.
1970739 if(toogam) return;
18177
18178 1970739 int32_t bx = x.getInt()&0xF0;
18179 1970739 int32_t bx2 = int32_t(x+8)&0xF0;
18180 1970739 int32_t by = y.getInt()&0xF0;
18181
18182
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 486594 times.
✓ Branch 2 taken 385430 times.
✓ Branch 3 taken 539847 times.
✓ Branch 4 taken 558868 times.
1970739 switch(dir)
18183 {
18184 case up:
18185
4/4
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 417700 times.
✓ Branch 2 taken 1004 times.
✓ Branch 3 taken 67890 times.
486594 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18186
18187 486594 break;
18188
18189 case down:
18190 385430 by+=16;
18191 385430 break;
18192
18193 case left:
18194
2/2
✓ Branch 0 taken 247982 times.
✓ Branch 1 taken 291865 times.
539847 if((((int32_t)x)&0x0F)<8)
18195 291865 bx-=16;
18196
18197
2/2
✓ Branch 0 taken 327472 times.
✓ Branch 1 taken 212375 times.
539847 if(y.getInt()&8)
18198 {
18199 212375 by+=16;
18200 212375 }
18201
18202 539847 bx2=bx;
18203 539847 break;
18204
18205 case right:
18206 558868 bx+=16;
18207
18208
2/2
✓ Branch 0 taken 349438 times.
✓ Branch 1 taken 209430 times.
558868 if(y.getInt()&8)
18209 {
18210 209430 by+=16;
18211 209430 }
18212
18213 558868 bx2=bx;
18214 558868 break;
18215 }
18216
18217 1970739 bool found1=false;
18218 1970739 bool found2=false;
18219 1970739 int32_t foundlayer = -1;
18220 1970739 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18221 1970739 newcombo const& cmb = combobuf[cid1];
18222 1970739 newcombo const& cmb2 = combobuf[cid2];
18223 // Layer 0 is overridden by Locked Doors
18224
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1970739 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1970739 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
18225 {
18226 found1=true;
18227 foundlayer = 0;
18228 }
18229
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1970739 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1970739 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
18230 {
18231 found2=true;
18232 foundlayer = 0;
18233 }
18234
18235
2/2
✓ Branch 0 taken 3941478 times.
✓ Branch 1 taken 1970739 times.
5912217 for (int32_t i = 0; i <= 1; ++i)
18236 {
18237
2/2
✓ Branch 0 taken 3606370 times.
✓ Branch 1 taken 335108 times.
3941478 if(tmpscr2[i].valid!=0)
18238 {
18239
1/2
✓ Branch 0 taken 335108 times.
✗ Branch 1 not taken.
335108 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18240 {
18241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 335108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
335108 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 335108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
335108 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18243 335108 }
18244 else
18245 {
18246 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18247 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18248 }
18249 335108 }
18250 3941478 }
18251
18252
18253 // Layers
18254
2/4
✓ Branch 0 taken 1970739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1970739 times.
1970739 if(!(found1 || found2))
18255 {
18256 1970739 foundlayer = -1;
18257
2/2
✓ Branch 0 taken 1970739 times.
✓ Branch 1 taken 3941478 times.
5912217 for(int32_t i=0; i<2; i++)
18258 {
18259 3941478 cid1 = MAPCOMBO2(i, bx, by);
18260 3941478 cid2 = MAPCOMBO2(i, bx2, by);
18261 3941478 newcombo const& cmb = combobuf[cid1];
18262 3941478 newcombo const& cmb2 = combobuf[cid2];
18263
2/2
✓ Branch 0 taken 1970739 times.
✓ Branch 1 taken 1970739 times.
3941478 if (i == 0)
18264 {
18265
1/2
✓ Branch 0 taken 1970739 times.
✗ Branch 1 not taken.
1970739 if(tmpscr2[1].valid!=0)
18266 {
18267 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18268 {
18269 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
18270 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
18271 }
18272 else
18273 {
18274 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18275 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18276 }
18277 }
18278 1970739 }
18279
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3941478 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3941478 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18280 {
18281 found1=true;
18282 foundlayer = i+1;
18283 //zprint("Found layer: %d \n", i);
18284 break;
18285 }
18286
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3941478 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3941478 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
18287 {
18288 found2=true;
18289 foundlayer = i+1;
18290 //zprint("Found layer: %d \n", i);
18291 break;
18292 }
18293 3941478 }
18294 1970739 }
18295
18296
2/4
✓ Branch 0 taken 1970739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1970739 times.
✗ Branch 3 not taken.
1970739 if(!(found1 || found2) || pushing<8)
18297 {
18298 1970739 return;
18299 }
18300 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
18301 if(!try_locked_combo(cmb3))
18302 return;
18303
18304 if(cmb.usrflags&cflag16)
18305 {
18306 setxmapflag(1<<cmb.attribytes[5]);
18307 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18308 }
18309 else
18310 {
18311 setmapflag(mLOCKBLOCK);
18312 remove_lockblocks((currscr>=128)?1:0);
18313 }
18314 if ( cmb3.usrflags&cflag3 )
18315 {
18316 if ( (cmb3.attribytes[3]) )
18317 sfx(cmb3.attribytes[3]);
18318 }
18319 else sfx(WAV_DOOR);
18320 1970739 }
18321
18322 1970739 void HeroClass::oldcheckbosslockblock()
18323 {
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970739 times.
1970739 if(toogam) return;
18325
18326 1970739 int32_t bx = x.getInt()&0xF0;
18327 1970739 int32_t bx2 = int32_t(x+8)&0xF0;
18328 1970739 int32_t by = y.getInt()&0xF0;
18329
18330
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 486594 times.
✓ Branch 2 taken 385430 times.
✓ Branch 3 taken 539847 times.
✓ Branch 4 taken 558868 times.
1970739 switch(dir)
18331 {
18332 case up:
18333
4/4
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 417700 times.
✓ Branch 2 taken 1004 times.
✓ Branch 3 taken 67890 times.
486594 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18334
18335 486594 break;
18336
18337 case down:
18338 385430 by+=16;
18339 385430 break;
18340
18341 case left:
18342
2/2
✓ Branch 0 taken 247982 times.
✓ Branch 1 taken 291865 times.
539847 if((((int32_t)x)&0x0F)<8)
18343 291865 bx-=16;
18344
18345
2/2
✓ Branch 0 taken 327472 times.
✓ Branch 1 taken 212375 times.
539847 if(y.getInt()&8)
18346 {
18347 212375 by+=16;
18348 212375 }
18349
18350 539847 bx2=bx;
18351 539847 break;
18352
18353 case right:
18354 558868 bx+=16;
18355
18356
2/2
✓ Branch 0 taken 349438 times.
✓ Branch 1 taken 209430 times.
558868 if(y.getInt()&8)
18357 {
18358 209430 by+=16;
18359 209430 }
18360
18361 558868 bx2=bx;
18362 558868 break;
18363 }
18364
18365
18366 1970739 bool found1 = false;
18367 1970739 bool found2 = false;
18368 1970739 int32_t foundlayer = -1;
18369 1970739 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18370 1970739 newcombo const& cmb = combobuf[cid1];
18371 1970739 newcombo const& cmb2 = combobuf[cid2];
18372 // Layer 0 is overridden by Locked Doors
18373
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1970739 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1970739 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
18374 {
18375 found1 = true;
18376 foundlayer = 0;
18377 }
18378
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1970739 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1970739 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
18379 {
18380 found2 = true;
18381 foundlayer = 0;
18382 }
18383
18384
2/2
✓ Branch 0 taken 3941478 times.
✓ Branch 1 taken 1970739 times.
5912217 for (int32_t i = 0; i <= 1; ++i)
18385 {
18386
2/2
✓ Branch 0 taken 3606370 times.
✓ Branch 1 taken 335108 times.
3941478 if (tmpscr2[i].valid != 0)
18387 {
18388
1/2
✓ Branch 0 taken 335108 times.
✗ Branch 1 not taken.
335108 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18389 {
18390
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 335108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
335108 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18391
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 335108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
335108 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18392 335108 }
18393 else
18394 {
18395 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18396 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18397 }
18398 335108 }
18399 3941478 }
18400
18401
18402 // Layers
18403
2/4
✓ Branch 0 taken 1970739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1970739 times.
1970739 if (!(found1 || found2))
18404 {
18405 1970739 foundlayer = -1;
18406
2/2
✓ Branch 0 taken 1970739 times.
✓ Branch 1 taken 3941478 times.
5912217 for (int32_t i = 0; i < 2; i++)
18407 {
18408 3941478 cid1 = MAPCOMBO2(i, bx, by);
18409 3941478 cid2 = MAPCOMBO2(i, bx2, by);
18410 3941478 newcombo const& cmb = combobuf[cid1];
18411 3941478 newcombo const& cmb2 = combobuf[cid2];
18412
2/2
✓ Branch 0 taken 1970739 times.
✓ Branch 1 taken 1970739 times.
3941478 if (i == 0)
18413 {
18414
1/2
✓ Branch 0 taken 1970739 times.
✗ Branch 1 not taken.
1970739 if (tmpscr2[1].valid != 0)
18415 {
18416 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18417 {
18418 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18419 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18420 }
18421 else
18422 {
18423 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18424 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18425 }
18426 }
18427 1970739 }
18428
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3941478 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3941478 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
18429 {
18430 found1 = true;
18431 foundlayer = i;
18432 break;
18433 }
18434
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3941478 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3941478 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
18435 {
18436 found2 = true;
18437 foundlayer = i;
18438 break;
18439 }
18440 3941478 }
18441 1970739 }
18442
18443
2/4
✓ Branch 0 taken 1970739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1970739 times.
✗ Branch 3 not taken.
1970739 if (!(found1 || found2) || pushing < 8)
18444 {
18445 1970739 return;
18446 }
18447 int32_t cid = found1 ? cid1 : cid2;
18448
18449 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18450
18451
18452 // Run Boss Key Script
18453 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18454 for ( int32_t q = 0; q < MAXITEMS; ++q )
18455 {
18456 if ( itemsbuf[q].family == itype_bosskey )
18457 {
18458 key_item = q; break;
18459 }
18460 }
18461 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18462 {
18463 ri = &(itemScriptData[key_item]);
18464 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18465 ri->Clear();
18466 item_doscript[key_item] = 1;
18467 itemscriptInitialised[key_item] = 0;
18468 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18469 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18470 }
18471
18472 if(cmb.usrflags&cflag16)
18473 {
18474 setxmapflag(1<<cmb.attribytes[5]);
18475 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18476 }
18477 else
18478 {
18479 setmapflag(mBOSSLOCKBLOCK);
18480 remove_bosslockblocks((currscr>=128)?1:0);
18481 }
18482 if ( (combobuf[cid].attribytes[3]) )
18483 sfx(combobuf[cid].attribytes[3]);
18484 1970739 }
18485
18486 5912217 void HeroClass::oldcheckchest(int32_t type)
18487 {
18488 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
18489
3/6
✓ Branch 0 taken 5912217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5912217 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5912217 times.
5912217 if(toogam || z>0 || fakez > 0) return;
18490
2/2
✓ Branch 0 taken 5812758 times.
✓ Branch 1 taken 99459 times.
5912217 if(pushing<8) return;
18491 99459 int32_t bx = x.getInt()&0xF0;
18492 99459 int32_t bx2 = int32_t(x+8)&0xF0;
18493 99459 int32_t by = y.getInt()&0xF0;
18494
18495
3/4
✓ Branch 0 taken 43245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28914 times.
✓ Branch 3 taken 27300 times.
99459 switch(dir)
18496 {
18497 case up:
18498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27300 times.
27300 if(isSideViewHero()) return;
18499
18500
3/4
✓ Branch 0 taken 8304 times.
✓ Branch 1 taken 18996 times.
✓ Branch 2 taken 8304 times.
✗ Branch 3 not taken.
27300 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18501
18502 27300 break;
18503
18504 case left:
18505 case right:
18506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43245 times.
43245 if(isSideViewHero()) break;
18507 [[fallthrough]];
18508 case down:
18509 72159 return;
18510 }
18511
18512 27300 bool found=false;
18513 27300 bool itemflag=false;
18514
18515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27300 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27300 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
18516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27300 times.
27300 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
18517 {
18518 found=true;
18519 }
18520
2/2
✓ Branch 0 taken 54600 times.
✓ Branch 1 taken 27300 times.
81900 for (int32_t i = 0; i <= 1; ++i)
18521 {
18522
2/2
✓ Branch 0 taken 45723 times.
✓ Branch 1 taken 8877 times.
54600 if(tmpscr2[i].valid!=0)
18523 {
18524
1/2
✓ Branch 0 taken 8877 times.
✗ Branch 1 not taken.
8877 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18525 {
18526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8877 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8877 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8877 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8877 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18528 8877 }
18529 else
18530 {
18531 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18532 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18533 }
18534 8877 }
18535 54600 }
18536
18537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27300 times.
27300 if(!found)
18538 {
18539
2/2
✓ Branch 0 taken 27300 times.
✓ Branch 1 taken 54600 times.
81900 for(int32_t i=0; i<2; i++)
18540 {
18541
2/2
✓ Branch 0 taken 27300 times.
✓ Branch 1 taken 27300 times.
54600 if (i == 0)
18542 {
18543
1/2
✓ Branch 0 taken 27300 times.
✗ Branch 1 not taken.
27300 if(tmpscr2[1].valid!=0)
18544 {
18545 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18546 {
18547 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18548 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18549 }
18550 else
18551 {
18552 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18553 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18554 }
18555 }
18556 27300 }
18557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54600 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
18558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54600 times.
54600 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
18559 {
18560 found=true;
18561 break;
18562 }
18563 54600 }
18564 27300 }
18565
18566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27300 times.
27300 if(!found)
18567 {
18568 27300 return;
18569 }
18570
18571 switch(type)
18572 {
18573 case cLOCKEDCHEST:
18574 if(!usekey()) return;
18575
18576 setmapflag(mLOCKEDCHEST);
18577 break;
18578
18579 case cCHEST:
18580 setmapflag(mCHEST);
18581 break;
18582
18583 case cBOSSCHEST:
18584 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18585 // Run Boss Key Script
18586 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18587 for ( int32_t q = 0; q < MAXITEMS; ++q )
18588 {
18589 if ( itemsbuf[q].family == itype_bosskey )
18590 {
18591 key_item = q; break;
18592 }
18593 }
18594 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18595 {
18596 ri = &(itemScriptData[key_item]);
18597 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18598 ri->Clear();
18599 item_doscript[key_item] = 1;
18600 itemscriptInitialised[key_item] = 0;
18601 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18602 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18603 }
18604 setmapflag(mBOSSCHEST);
18605 break;
18606 }
18607
18608 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18609 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18610 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
18611 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
18612 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18613 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18614
18615 if(!itemflag)
18616 {
18617 for(int32_t i=0; i<2; i++)
18618 {
18619 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
18620 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
18621 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
18622 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
18623 }
18624 }
18625
18626 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
18627 {
18628 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
18629 }
18630 5912217 }
18631
18632 46730 void HeroClass::checkchest(int32_t type)
18633 {
18634
4/4
✓ Branch 0 taken 37384 times.
✓ Branch 1 taken 9346 times.
✓ Branch 2 taken 9346 times.
✓ Branch 3 taken 28038 times.
46730 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
18635
2/2
✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 37384 times.
46730 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
18636
2/2
✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 37384 times.
46730 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
18637
2/2
✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 37384 times.
46730 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
18638
2/2
✓ Branch 0 taken 18692 times.
✓ Branch 1 taken 28038 times.
46730 if(ischest)
18639 {
18640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28038 times.
28038 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
18641 {
18642 oldcheckchest(type);
18643 return;
18644 }
18645 28038 }
18646
3/4
✓ Branch 0 taken 18692 times.
✓ Branch 1 taken 28038 times.
✓ Branch 2 taken 18692 times.
✗ Branch 3 not taken.
46730 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
18647 {
18648 if(type == cLOCKBLOCK)
18649 oldchecklockblock();
18650 else if(type == cBOSSLOCKBLOCK)
18651 oldcheckbosslockblock();
18652 return;
18653 }
18654
4/6
✓ Branch 0 taken 46730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46130 times.
✓ Branch 3 taken 600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46130 times.
46730 if(toogam || z>0 || fakez > 0) return;
18655 46130 zfix bx, by;
18656 46130 zfix bx2, by2;
18657 46130 zfix fx(-1), fy(-1);
18658
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7475 times.
✓ Branch 2 taken 3600 times.
✓ Branch 3 taken 13775 times.
✓ Branch 4 taken 21280 times.
46130 switch(dir)
18659 {
18660 case up:
18661 7475 by = y + (bigHitbox ? -2 : 6);
18662 7475 by2 = by;
18663 7475 bx = x + 4;
18664 7475 bx2 = bx + 8;
18665 7475 break;
18666 case down:
18667 3600 by = y + 17;
18668 3600 by2 = by;
18669 3600 bx = x + 4;
18670 3600 bx2 = bx + 8;
18671 3600 break;
18672 case left:
18673 13775 by = y + (bigHitbox ? 0 : 8);
18674 13775 by2 = y + 8;
18675 13775 bx = x - 2;
18676 13775 bx2 = x - 2;
18677 13775 break;
18678 case right:
18679 21280 by = y + (bigHitbox ? 0 : 8);
18680 21280 by2 = y + 8;
18681 21280 bx = x + 17;
18682 21280 bx2 = x + 17;
18683 21280 break;
18684 }
18685
18686 46130 int32_t found = -1;
18687 46130 int32_t foundlayer = 0;
18688
18689 46130 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
18690
18691
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
46130 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
18692 {
18693 found = MAPCOMBO(bx,by);
18694 fx = bx; fy = by;
18695 for (int32_t i = 0; i <= 1; ++i)
18696 {
18697 if(tmpscr2[i].valid!=0)
18698 {
18699 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18700 {
18701 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18702 }
18703 else
18704 {
18705 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18706 }
18707 }
18708 }
18709 }
18710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
46130 if(found<0)
18711 {
18712 46130 cmb = &combobuf[MAPCOMBO(bx2,by2)];
18713
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
46130 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
18714 {
18715 found = MAPCOMBO(bx2,by2);
18716 for (int32_t i = 0; i <= 6; ++i)
18717 {
18718 if(tmpscr2[i].valid!=0)
18719 {
18720 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18721 {
18722 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
18723 {
18724 found = -1;
18725 break;
18726 }
18727 }
18728 else
18729 {
18730 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
18731 {
18732 found = -1;
18733 break;
18734 }
18735 }
18736 }
18737 }
18738 if(found != -1)
18739 {
18740 fx = bx2; fy = by2;
18741 }
18742 }
18743 46130 }
18744
18745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
46130 if(found<0)
18746 {
18747
2/2
✓ Branch 0 taken 46130 times.
✓ Branch 1 taken 276780 times.
322910 for(int32_t i=0; i<6; i++)
18748 {
18749 276780 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
18750
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
276780 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18751 {
18752 found = MAPCOMBO2(i,bx,by);
18753 for(int32_t j = i+1; j < 6; ++j)
18754 {
18755 if (tmpscr2[j].valid!=0)
18756 {
18757 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18758 {
18759 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
18760 {
18761 found = -1;
18762 break;
18763 }
18764 }
18765 else
18766 {
18767 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
18768 {
18769 found = -1;
18770 break;
18771 }
18772 }
18773 }
18774 }
18775 if(found>-1)
18776 {
18777 foundlayer = i+1;
18778 fx = bx; fy = by;
18779 break;
18780 }
18781 }
18782 276780 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
18783
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
276780 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
18784 {
18785 found = MAPCOMBO2(i,bx2,by2);
18786 for(int32_t j = i+1; j < 6; ++j)
18787 {
18788 if (tmpscr2[j].valid!=0)
18789 {
18790 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18791 {
18792 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
18793 {
18794 found = -1;
18795 break;
18796 }
18797 }
18798 else
18799 {
18800 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
18801 {
18802 found = -1;
18803 break;
18804 }
18805 }
18806 }
18807 }
18808 if(found>-1)
18809 {
18810 foundlayer = i+1;
18811 fx = bx2; fy = by2;
18812 break;
18813 }
18814 }
18815 276780 }
18816 46130 }
18817
18818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
46130 if(found<0) return;
18819 cmb = &combobuf[found];
18820 switch(dir)
18821 {
18822 case up:
18823 if(cmb->usrflags&cflag10)
18824 return;
18825 break;
18826 case down:
18827 if(cmb->usrflags&cflag9)
18828 return;
18829 break;
18830 case left:
18831 if(cmb->usrflags&cflag12)
18832 return;
18833 break;
18834 case right:
18835 if(cmb->usrflags&cflag11)
18836 return;
18837 break;
18838 }
18839 int32_t intbtn = cmb->attribytes[2];
18840
18841 if(intbtn) //
18842 {
18843 if(cmb->usrflags & cflag13) //display prompt
18844 {
18845 int altcmb = cmb->attributes[2]/10000;
18846 prompt_combo = cmb->attributes[1]/10000;
18847 if(altcmb && ((islocked && !can_locked_combo(*cmb))
18848 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
18849 prompt_combo = altcmb;
18850 prompt_cset = cmb->attribytes[4];
18851 prompt_x = cmb->attrishorts[0];
18852 prompt_y = cmb->attrishorts[1];
18853 }
18854 if(!getIntBtnInput(intbtn, true, true, false, false))
18855 {
18856 return; //Button not pressed
18857 }
18858 }
18859 else if(pushing < 8) return; //Not pushing against chest enough
18860
18861 if(ischest)
18862 {
18863 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
18864 }
18865 else if(islockblock)
18866 {
18867 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
18868 }
18869 if(intbtn && (cmb->usrflags & cflag13))
18870 prompt_combo = 0;
18871 46730 }
18872
18873 1981862 void HeroClass::checkgenpush()
18874 {
18875
4/4
✓ Branch 0 taken 33875 times.
✓ Branch 1 taken 1947987 times.
✓ Branch 2 taken 28030 times.
✓ Branch 3 taken 5845 times.
1981862 if(pushing < 8 || pushing % 8) return;
18876 5845 zfix bx, by;
18877 5845 zfix bx2, by2;
18878
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1660 times.
✓ Branch 2 taken 1698 times.
✓ Branch 3 taken 1062 times.
✓ Branch 4 taken 1425 times.
5845 switch(dir)
18879 {
18880 case up:
18881 1660 by = y + (bigHitbox ? -2 : 6);
18882 1660 by2 = by;
18883 1660 bx = x + 4;
18884 1660 bx2 = bx + 8;
18885 1660 break;
18886 case down:
18887 1698 by = y + 17;
18888 1698 by2 = by;
18889 1698 bx = x + 4;
18890 1698 bx2 = bx + 8;
18891 1698 break;
18892 case left:
18893 1062 by = y + (bigHitbox ? 0 : 8);
18894 1062 by2 = y + 8;
18895 1062 bx = x - 2;
18896 1062 bx2 = x - 2;
18897 1062 break;
18898 case right:
18899 1425 by = y + (bigHitbox ? 0 : 8);
18900 1425 by2 = y + 8;
18901 1425 bx = x + 17;
18902 1425 bx2 = x + 17;
18903 1425 break;
18904 }
18905 5845 auto pos1 = COMBOPOS(bx,by);
18906 5845 auto pos2 = COMBOPOS(bx2,by2);
18907
2/2
✓ Branch 0 taken 5845 times.
✓ Branch 1 taken 40915 times.
46760 for(auto layer = 0; layer < 7; ++layer)
18908 {
18909 40915 mapscr* tmp = FFCore.tempScreens[layer];
18910
18911 40915 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
18912
1/2
✓ Branch 0 taken 40915 times.
✗ Branch 1 not taken.
40915 if(cmb1.triggerflags[1] & combotriggerPUSH)
18913 do_trigger_combo(layer,pos1);
18914
18915
2/2
✓ Branch 0 taken 29561 times.
✓ Branch 1 taken 11354 times.
40915 if(pos1==pos2) continue;
18916
18917 11354 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
18918
1/2
✓ Branch 0 taken 11354 times.
✗ Branch 1 not taken.
11354 if(cmb2.triggerflags[1] & combotriggerPUSH)
18919 do_trigger_combo(layer,pos2);
18920 11354 }
18921
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5740 times.
5845 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
18922 {
18923 105 word c = tmpscr->numFFC();
18924
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1283 times.
1388 for(word i=0; i<c; i++)
18925 {
18926
4/4
✓ Branch 0 taken 1229 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1226 times.
1283 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
18927 {
18928 57 ffcdata& ffc = tmpscr->ffcs[i];
18929 57 newcombo const& cmb3 = combobuf[ffc.getData()];
18930
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(cmb3.triggerflags[1] & combotriggerPUSH)
18931 {
18932 do_trigger_combo_ffc(i);
18933 break;
18934 }
18935 57 }
18936 1283 }
18937 105 }
18938 1981862 }
18939
18940 1981862 void HeroClass::checksigns() //Also checks for generic trigger buttons
18941 {
18942
4/6
✓ Branch 0 taken 1981862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981742 times.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1981742 times.
1981862 if(toogam || z>0 || fakez>0) return;
18943
5/6
✓ Branch 0 taken 1963821 times.
✓ Branch 1 taken 17921 times.
✓ Branch 2 taken 24954 times.
✓ Branch 3 taken 1938867 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24954 times.
1981742 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
18944 17921 return; //Don't overwrite a message waiting to be dismissed
18945 1963821 zfix bx, by;
18946 1963821 zfix bx2, by2;
18947 1963821 zfix fx(-1), fy(-1);
18948
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 473971 times.
✓ Branch 2 taken 386126 times.
✓ Branch 3 taken 540338 times.
✓ Branch 4 taken 563386 times.
1963821 switch(dir)
18949 {
18950 case up:
18951 473971 by = y + (bigHitbox ? -2 : 6);
18952 473971 by2 = by;
18953 473971 bx = x + 4;
18954 473971 bx2 = bx + 8;
18955 473971 break;
18956 case down:
18957 386126 by = y + 17;
18958 386126 by2 = by;
18959 386126 bx = x + 4;
18960 386126 bx2 = bx + 8;
18961 386126 break;
18962 case left:
18963 540338 by = y + (bigHitbox ? 0 : 8);
18964 540338 by2 = y + 8;
18965 540338 bx = x - 2;
18966 540338 bx2 = x - 2;
18967 540338 break;
18968 case right:
18969 563386 by = y + (bigHitbox ? 0 : 8);
18970 563386 by2 = y + 8;
18971 563386 bx = x + 17;
18972 563386 bx2 = x + 17;
18973 563386 break;
18974 }
18975
18976 1963821 int32_t found = -1;
18977 1963821 int32_t foundffc = -1;
18978 1963821 int32_t found_lyr = 0;
18979 1963821 bool found_sign = false;
18980 1963821 int32_t tmp_cid = MAPCOMBO(bx,by);
18981 1963821 newcombo const* tmp_cmb = &combobuf[tmp_cid];
18982
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1963821 times.
✓ Branch 2 taken 1963821 times.
✗ Branch 3 not taken.
3927642 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
18983 1963821 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
18984 {
18985 found = tmp_cid;
18986 fx = bx; fy = by;
18987 for (int32_t i = 0; i <= 1; ++i)
18988 {
18989 if(tmpscr2[i].valid!=0)
18990 {
18991 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18992 {
18993 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18994 }
18995 else
18996 {
18997 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18998 }
18999 }
19000 }
19001 }
19002 1963821 tmp_cid = MAPCOMBO(bx2,by2);
19003 1963821 tmp_cmb = &combobuf[tmp_cid];
19004
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1963821 times.
✓ Branch 2 taken 1963821 times.
✗ Branch 3 not taken.
3927642 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19005 1963821 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
19006 {
19007 found = tmp_cid;
19008 fx = bx2; fy = by2;
19009 for (int32_t i = 0; i <= 1; ++i)
19010 {
19011 if(tmpscr2[i].valid!=0)
19012 {
19013 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19014 {
19015 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19016 }
19017 else
19018 {
19019 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19020 }
19021 }
19022 }
19023 }
19024
19025
2/2
✓ Branch 0 taken 1955022 times.
✓ Branch 1 taken 8799 times.
1963821 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19026 {
19027 8799 word c = tmpscr->numFFC();
19028
2/2
✓ Branch 0 taken 8799 times.
✓ Branch 1 taken 129337 times.
138136 for(word i=0; i<c; i++)
19029 {
19030
4/4
✓ Branch 0 taken 128274 times.
✓ Branch 1 taken 1063 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 128230 times.
129337 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19031 {
19032 1107 ffcdata& ffc = tmpscr->ffcs[i];
19033 1107 tmp_cmb = &combobuf[ffc.getData()];
19034
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1107 times.
1107 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19035 1107 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
19036 {
19037 foundffc = i;
19038 break;
19039 }
19040 1107 }
19041 129337 }
19042 8799 }
19043
19044
2/4
✓ Branch 0 taken 1963821 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1963821 times.
1963821 if(found<0 && foundffc < 0)
19045 {
19046
2/2
✓ Branch 0 taken 1963821 times.
✓ Branch 1 taken 11782926 times.
13746747 for(int32_t i=0; i<6; i++)
19047 {
19048 11782926 tmp_cid = MAPCOMBO2(i,bx,by);
19049 11782926 tmp_cmb = &combobuf[tmp_cid];
19050
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11782926 times.
✓ Branch 2 taken 11782926 times.
✗ Branch 3 not taken.
23565852 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19051 11782926 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
19052 {
19053 found = tmp_cid;
19054 found_lyr = i+1;
19055 fx = bx; fy = by;
19056 if (i == 0 && tmpscr2[1].valid!=0)
19057 {
19058 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19059 {
19060 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19061 }
19062 else
19063 {
19064 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19065 }
19066 }
19067 }
19068 11782926 tmp_cid = MAPCOMBO2(i,bx2,by2);
19069 11782926 tmp_cmb = &combobuf[tmp_cid];
19070
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11782926 times.
✓ Branch 2 taken 11782926 times.
✗ Branch 3 not taken.
23565852 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19071 11782926 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
19072 {
19073 found = tmp_cid;
19074 found_lyr = i+1;
19075 fx = bx2; fy = by2;
19076 if (i == 0 && tmpscr2[1].valid!=0)
19077 {
19078 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19079 {
19080 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19081 }
19082 else
19083 {
19084 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19085 }
19086 }
19087 }
19088
1/2
✓ Branch 0 taken 11782926 times.
✗ Branch 1 not taken.
11782926 if(found>-1) break;
19089 11782926 }
19090 1963821 }
19091
19092
2/4
✓ Branch 0 taken 1963821 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1963821 times.
1963821 if(found<0&&foundffc<0) return;
19093 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
19094
19095 byte signInput = 0;
19096 bool didsign = false;
19097 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
19098 {
19099 switch(dir)
19100 {
19101 case up:
19102 if(cmb.usrflags&cflag10)
19103 goto endsigns;
19104 break;
19105 case down:
19106 if(cmb.usrflags&cflag9)
19107 goto endsigns;
19108 break;
19109 case left:
19110 if(cmb.usrflags&cflag12)
19111 goto endsigns;
19112 break;
19113 case right:
19114 if(cmb.usrflags&cflag11)
19115 goto endsigns;
19116 break;
19117 }
19118 int32_t intbtn = cmb.attribytes[2];
19119
19120 if(intbtn) //
19121 {
19122 signInput = getIntBtnInput(intbtn, true, true, false, false);
19123 if(!signInput)
19124 {
19125 if(cmb.usrflags & cflag13) //display prompt
19126 {
19127 prompt_combo = cmb.attributes[1]/10000;
19128 prompt_cset = cmb.attribytes[4];
19129 prompt_x = cmb.attrishorts[0];
19130 prompt_y = cmb.attrishorts[1];
19131 }
19132 goto endsigns; //Button not pressed
19133 }
19134 }
19135 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
19136
19137 trigger_sign(cmb);
19138 didsign = true;
19139 }
19140 endsigns:
19141 if(!cmb.triggerbtn) return;
19142 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
19143 switch(dir)
19144 {
19145 case down:
19146 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
19147 return;
19148 break;
19149 case up:
19150 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
19151 return;
19152 break;
19153 case right:
19154 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
19155 return;
19156 break;
19157 case left:
19158 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
19159 return;
19160 break;
19161 }
19162 if(getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput))
19163 {
19164 if (foundffc >= 0)
19165 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
19166 else
19167 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
19168 }
19169 else if(cmb.type == cBUTTONPROMPT)
19170 {
19171 prompt_combo = cmb.attributes[0]/10000;
19172 prompt_cset = cmb.attribytes[0];
19173 prompt_x = cmb.attrishorts[0];
19174 prompt_y = cmb.attrishorts[1];
19175 }
19176 else if(cmb.prompt_cid)
19177 {
19178 prompt_combo = cmb.prompt_cid;
19179 prompt_cset = cmb.prompt_cs;
19180 prompt_x = cmb.prompt_x;
19181 prompt_y = cmb.prompt_y;
19182 }
19183 1981862 }
19184
19185 1980088 void HeroClass::checklocked()
19186 {
19187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980088 times.
1980088 if(toogam) return; //Walk through walls.
19188
19189
2/2
✓ Branch 0 taken 1514323 times.
✓ Branch 1 taken 465765 times.
1980088 if(!isdungeon()) return;
19190
19191
3/4
✓ Branch 0 taken 1514323 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2630 times.
✓ Branch 3 taken 1511693 times.
1514323 if( !diagonalMovement && pushing!=8) return;
19192 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
19193 */
19194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2630 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2630 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
19195
19196
19197 2630 bool found = false;
19198
2/2
✓ Branch 0 taken 10520 times.
✓ Branch 1 taken 2630 times.
13150 for ( int32_t q = 0; q < 4; q++ ) {
19199
4/4
✓ Branch 0 taken 10163 times.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 10052 times.
10520 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
19200 10520 }
19201
19202
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 2184 times.
2630 if ( !found ) return;
19203
19204 446 int32_t si = (currmap<<7) + currscr;
19205 446 int32_t di = 0;
19206
19207
19208
19209
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
19210 {
19211 //Up door
19212 if ( y <= 32 && x >= 112 && x <= 128 )
19213 {
19214 if (
19215 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
19216
19217 )
19218 {
19219 di = nextscr(up);
19220 if(tmpscr->door[0]==dLOCKED)
19221 {
19222 if(usekey())
19223 {
19224 putdoor(scrollbuf,0,up,dUNLOCKED);
19225 tmpscr->door[0]=dUNLOCKED;
19226 setmapflag(si, mDOOR_UP);
19227
19228 if(di != 0xFFFF)
19229 setmapflag(di, mDOOR_DOWN);
19230 sfx(WAV_DOOR);
19231 markBmap(-1);
19232 }
19233 else return;
19234 }
19235 else if(tmpscr->door[0]==dBOSS)
19236 {
19237 if(game->lvlitems[dlevel]&liBOSSKEY)
19238 {
19239 putdoor(scrollbuf,0,up,dOPENBOSS);
19240 tmpscr->door[0]=dOPENBOSS;
19241 setmapflag(si, mDOOR_UP);
19242
19243 if(di != 0xFFFF)
19244 setmapflag(di, mDOOR_DOWN);
19245 sfx(WAV_DOOR);
19246 markBmap(-1);
19247 // Run Boss Key Script
19248 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19249 for ( int32_t q = 0; q < MAXITEMS; ++q )
19250 {
19251 if ( itemsbuf[q].family == itype_bosskey )
19252 {
19253 key_item = q; break;
19254 }
19255 }
19256 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19257 {
19258 ri = &(itemScriptData[key_item]);
19259 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19260 ri->Clear();
19261 item_doscript[key_item] = 1;
19262 itemscriptInitialised[key_item] = 0;
19263 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19264 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19265 }
19266 }
19267 else return;
19268
19269 }
19270
19271 }
19272 }
19273 //Down
19274 if ( y >= 128 && x >= 112 && x <= 128 )
19275 {
19276 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
19277 {
19278 di = nextscr(down);
19279 if(tmpscr->door[1]==dLOCKED)
19280 {
19281 if(usekey())
19282 {
19283 putdoor(scrollbuf,0,down,dUNLOCKED);
19284 tmpscr->door[1]=dUNLOCKED;
19285 setmapflag(si, mDOOR_DOWN);
19286
19287 if(di != 0xFFFF)
19288 setmapflag(di, mDOOR_UP);
19289 sfx(WAV_DOOR);
19290 markBmap(-1);
19291 }
19292 else return;
19293 }
19294 else if(tmpscr->door[1]==dBOSS)
19295 {
19296 if(game->lvlitems[dlevel]&liBOSSKEY)
19297 {
19298 putdoor(scrollbuf,0,down,dOPENBOSS);
19299 tmpscr->door[1]=dOPENBOSS;
19300 setmapflag(si, mDOOR_DOWN);
19301
19302 if(di != 0xFFFF)
19303 setmapflag(di, mDOOR_UP);
19304 sfx(WAV_DOOR);
19305 markBmap(-1);
19306 // Run Boss Key Script
19307 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19308 for ( int32_t q = 0; q < MAXITEMS; ++q )
19309 {
19310 if ( itemsbuf[q].family == itype_bosskey )
19311 {
19312 key_item = q; break;
19313 }
19314 }
19315 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19316 {
19317 ri = &(itemScriptData[key_item]);
19318 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19319 ri->Clear();
19320 item_doscript[key_item] = 1;
19321 itemscriptInitialised[key_item] = 0;
19322 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19323 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19324 }
19325 }
19326 else return;
19327 }
19328 }
19329 }
19330 //left
19331 if ( y > 72 && y < 88 && x <= 32 )
19332 {
19333 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
19334 {
19335 di = nextscr(left);
19336 if(tmpscr->door[2]==dLOCKED)
19337 {
19338 if(usekey())
19339 {
19340 putdoor(scrollbuf,0,left,dUNLOCKED);
19341 tmpscr->door[2]=dUNLOCKED;
19342 setmapflag(si, mDOOR_LEFT);
19343
19344 if(di != 0xFFFF)
19345 setmapflag(di, mDOOR_RIGHT);
19346 sfx(WAV_DOOR);
19347 markBmap(-1);
19348 }
19349 else return;
19350 }
19351 else if(tmpscr->door[2]==dBOSS)
19352 {
19353 if(game->lvlitems[dlevel]&liBOSSKEY)
19354 {
19355 putdoor(scrollbuf,0,left,dOPENBOSS);
19356 tmpscr->door[2]=dOPENBOSS;
19357 setmapflag(si, mDOOR_LEFT);
19358
19359 if(di != 0xFFFF)
19360 setmapflag(di, mDOOR_RIGHT);
19361 sfx(WAV_DOOR);
19362 markBmap(-1);
19363 // Run Boss Key Script
19364 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19365 for ( int32_t q = 0; q < MAXITEMS; ++q )
19366 {
19367 if ( itemsbuf[q].family == itype_bosskey )
19368 {
19369 key_item = q; break;
19370 }
19371 }
19372 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19373 {
19374 ri = &(itemScriptData[key_item]);
19375 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19376 ri->Clear();
19377 item_doscript[key_item] = 1;
19378 itemscriptInitialised[key_item] = 0;
19379 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19380 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19381 }
19382 }
19383 else return;
19384 }
19385 }
19386 }
19387
19388
19389 //right
19390 if ( ( y > 72 && y < 88 ) && x >= 208 )
19391 //!( (y<=72||y>=88) && x<206 ) )
19392 //y<=72||y>=88):y!=80) || x<208)
19393 {
19394 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
19395 {
19396 di = nextscr(right);
19397 if(tmpscr->door[right]==dLOCKED)
19398 {
19399 if(usekey())
19400 {
19401 putdoor(scrollbuf,0,right,dUNLOCKED);
19402 tmpscr->door[3]=dUNLOCKED;
19403 setmapflag(si, mDOOR_RIGHT);
19404
19405 if(di != 0xFFFF)
19406 setmapflag(di, mDOOR_LEFT);
19407 sfx(WAV_DOOR);
19408 markBmap(-1);
19409 }
19410 else return;
19411 }
19412 else if(tmpscr->door[right]==dBOSS)
19413 {
19414 if(game->lvlitems[dlevel]&liBOSSKEY)
19415 {
19416 putdoor(scrollbuf,0,right,dOPENBOSS);
19417 tmpscr->door[3]=dOPENBOSS;
19418 setmapflag(si, mDOOR_RIGHT);
19419
19420 if(di != 0xFFFF)
19421 setmapflag(di, mDOOR_LEFT);
19422 sfx(WAV_DOOR);
19423 markBmap(-1);
19424 // Run Boss Key Script
19425 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19426 for ( int32_t q = 0; q < MAXITEMS; ++q )
19427 {
19428 if ( itemsbuf[q].family == itype_bosskey )
19429 {
19430 key_item = q; break;
19431 }
19432 }
19433 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19434 {
19435 ri = &(itemScriptData[key_item]);
19436 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19437 ri->Clear();
19438 item_doscript[key_item] = 1;
19439 itemscriptInitialised[key_item] = 0;
19440 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19441 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19442 }
19443 }
19444 else return;
19445 }
19446
19447 }
19448 }
19449 }
19450 else
19451 {
19452 //orthogonal movement
19453 //Up door
19454
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 349 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 62 times.
446 if ( y<=32 && x == 120 )
19455 //!( y>32 && (x!=120) ))
19456 {
19457
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 1 times.
62 switch ( dir )
19458 {
19459 case up:
19460 case r_up:
19461 case l_up:
19462 {
19463 61 di = nextscr(up);
19464
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 11 times.
61 if(tmpscr->door[0]==dLOCKED)
19465 {
19466
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 1 times.
50 if(usekey())
19467 {
19468 49 putdoor(scrollbuf,0,up,dUNLOCKED);
19469 49 tmpscr->door[0]=dUNLOCKED;
19470 49 setmapflag(si, mDOOR_UP);
19471
19472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(di != 0xFFFF)
19473 49 setmapflag(di, mDOOR_DOWN);
19474 49 sfx(WAV_DOOR);
19475 49 markBmap(-1);
19476 49 }
19477 1 else return;
19478 49 }
19479
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
11 else if(tmpscr->door[0]==dBOSS)
19480 {
19481
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(game->lvlitems[dlevel]&liBOSSKEY)
19482 {
19483 8 putdoor(scrollbuf,0,up,dOPENBOSS);
19484 8 tmpscr->door[0]=dOPENBOSS;
19485 8 setmapflag(si, mDOOR_UP);
19486
19487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(di != 0xFFFF)
19488 8 setmapflag(di, mDOOR_DOWN);
19489 8 sfx(WAV_DOOR);
19490 8 markBmap(-1);
19491 // Run Boss Key Script
19492 8 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544 times.
544 for ( int32_t q = 0; q < MAXITEMS; ++q )
19494 {
19495
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 8 times.
544 if ( itemsbuf[q].family == itype_bosskey )
19496 {
19497 8 key_item = q; break;
19498 }
19499 536 }
19500
2/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19501 {
19502 ri = &(itemScriptData[key_item]);
19503 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19504 ri->Clear();
19505 item_doscript[key_item] = 1;
19506 itemscriptInitialised[key_item] = 0;
19507 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19508 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19509 }
19510 8 }
19511 1 else return;
19512 8 }
19513 59 break;
19514 }
19515 1 default: break;
19516
19517 }
19518 60 }
19519 //Down
19520
4/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 13 times.
444 if ( y >= 128 && x == 120 )
19521 //!(y<128 && (x!=120) ) )
19522 {
19523
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 switch(dir)
19524 {
19525 case down:
19526 case l_down:
19527 case r_down:
19528 {
19529 12 di = nextscr(down);
19530
19531
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(tmpscr->door[1]==dLOCKED)
19532 {
19533
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(usekey())
19534 {
19535 7 putdoor(scrollbuf,0,down,dUNLOCKED);
19536 7 tmpscr->door[1]=dUNLOCKED;
19537 7 setmapflag(si, mDOOR_DOWN);
19538
19539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
19540 7 setmapflag(di, mDOOR_UP);
19541 7 sfx(WAV_DOOR);
19542 7 markBmap(-1);
19543 7 }
19544 1 else return;
19545 7 }
19546
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(tmpscr->door[1]==dBOSS)
19547 {
19548
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->lvlitems[dlevel]&liBOSSKEY)
19549 {
19550 2 putdoor(scrollbuf,0,down,dOPENBOSS);
19551 2 tmpscr->door[1]=dOPENBOSS;
19552 2 setmapflag(si, mDOOR_DOWN);
19553
19554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(di != 0xFFFF)
19555 2 setmapflag(di, mDOOR_UP);
19556 2 sfx(WAV_DOOR);
19557 2 markBmap(-1);
19558 // Run Boss Key Script
19559 2 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 for ( int32_t q = 0; q < MAXITEMS; ++q )
19561 {
19562
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
136 if ( itemsbuf[q].family == itype_bosskey )
19563 {
19564 2 key_item = q; break;
19565 }
19566 134 }
19567
2/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19568 {
19569 ri = &(itemScriptData[key_item]);
19570 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19571 ri->Clear();
19572 item_doscript[key_item] = 1;
19573 itemscriptInitialised[key_item] = 0;
19574 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19575 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19576 }
19577 2 }
19578 else return;
19579 2 }
19580 11 break;
19581 }
19582 1 default: break;
19583 }
19584 12 }
19585 //left
19586
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 26 times.
443 if ( y == 80 && x <= 32 )
19587 //!( (y!=80) && x>32 ) )
19588 {
19589
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
26 switch(dir)
19590 {
19591 case left:
19592 case l_up:
19593 case l_down:
19594 {
19595 25 di = nextscr(left);
19596
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 8 times.
25 if(tmpscr->door[2]==dLOCKED)
19597 {
19598
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 if(usekey())
19599 {
19600 16 putdoor(scrollbuf,0,left,dUNLOCKED);
19601 16 tmpscr->door[2]=dUNLOCKED;
19602 16 setmapflag(si, mDOOR_LEFT);
19603
19604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(di != 0xFFFF)
19605 16 setmapflag(di, mDOOR_RIGHT);
19606 16 sfx(WAV_DOOR);
19607 16 markBmap(-1);
19608 16 }
19609 1 else return;
19610 16 }
19611
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 else if(tmpscr->door[2]==dBOSS)
19612 {
19613
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if(game->lvlitems[dlevel]&liBOSSKEY)
19614 {
19615 3 putdoor(scrollbuf,0,left,dOPENBOSS);
19616 3 tmpscr->door[2]=dOPENBOSS;
19617 3 setmapflag(si, mDOOR_LEFT);
19618
19619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(di != 0xFFFF)
19620 3 setmapflag(di, mDOOR_RIGHT);
19621 3 sfx(WAV_DOOR);
19622 3 markBmap(-1);
19623 // Run Boss Key Script
19624 3 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for ( int32_t q = 0; q < MAXITEMS; ++q )
19626 {
19627
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3 times.
204 if ( itemsbuf[q].family == itype_bosskey )
19628 {
19629 3 key_item = q; break;
19630 }
19631 201 }
19632
2/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19633 {
19634 ri = &(itemScriptData[key_item]);
19635 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19636 ri->Clear();
19637 item_doscript[key_item] = 1;
19638 itemscriptInitialised[key_item] = 0;
19639 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19640 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19641 }
19642 3 }
19643 1 else return;
19644 3 }
19645
19646 23 break;
19647
19648 }
19649 1 default: break;
19650 }
19651 24 }
19652 //right
19653
4/4
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 36 times.
441 if ( y == 80 && x >= 208 )
19654 //!((y!=80) && x<208 ) )
19655 {
19656
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 switch(dir)
19657 {
19658 case right:
19659 case r_down:
19660 case r_up:
19661 {
19662 35 di = nextscr(right);
19663
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 12 times.
35 if(tmpscr->door[3]==dLOCKED)
19664 {
19665
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(usekey())
19666 {
19667 23 putdoor(scrollbuf,0,right,dUNLOCKED);
19668 23 tmpscr->door[3]=dUNLOCKED;
19669 23 setmapflag(si, mDOOR_RIGHT);
19670
19671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(di != 0xFFFF)
19672 23 setmapflag(di, mDOOR_LEFT);
19673 23 sfx(WAV_DOOR);
19674 23 markBmap(-1);
19675 23 }
19676 else return;
19677 23 }
19678
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5 times.
12 else if(tmpscr->door[3]==dBOSS)
19679 {
19680
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19681 {
19682 5 putdoor(scrollbuf,0,right,dOPENBOSS);
19683 5 tmpscr->door[3]=dOPENBOSS;
19684 5 setmapflag(si, mDOOR_RIGHT);
19685
19686
19687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(di != 0xFFFF)
19688 5 setmapflag(di, mDOOR_LEFT);
19689 5 sfx(WAV_DOOR);
19690 5 markBmap(-1);
19691 // Run Boss Key Script
19692 5 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 for ( int32_t q = 0; q < MAXITEMS; ++q )
19694 {
19695
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 5 times.
340 if ( itemsbuf[q].family == itype_bosskey )
19696 {
19697 5 key_item = q; break;
19698 }
19699 335 }
19700
2/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
19701 {
19702 ri = &(itemScriptData[key_item]);
19703 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19704 ri->Clear();
19705 item_doscript[key_item] = 1;
19706 itemscriptInitialised[key_item] = 0;
19707 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19708 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19709 }
19710
19711 5 }
19712 else return;
19713 5 }
19714
19715
19716 35 break;
19717 }
19718 1 default: break;
19719
19720 }
19721 36 }
19722 }
19723 1980088 }
19724
19725 1980088 void HeroClass::checkswordtap()
19726 {
19727
3/6
✓ Branch 0 taken 1226964 times.
✓ Branch 1 taken 753124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1226964 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1980088 if(attack!=wSword || charging<=0 || pushing<8) return;
19728
19729 int32_t bx=x;
19730 int32_t by=y+8;
19731
19732 switch(dir)
19733 {
19734 case up:
19735 if(!Up()) return;
19736
19737 by-=16;
19738 break;
19739
19740 case down:
19741 if(!Down()) return;
19742
19743 by+=16;
19744 bx+=8;
19745 break;
19746
19747 case left:
19748 if(!Left()) return;
19749
19750 bx-=16;
19751 by+=8;
19752 break;
19753
19754 case right:
19755 if(!Right()) return;
19756
19757 bx+=16;
19758 by+=8;
19759 break;
19760 }
19761
19762 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
19763
19764 attackclk=SWORDTAPFRAME;
19765 pushing=-8; //16 frames between taps
19766 tapping=true;
19767
19768 int32_t type = COMBOTYPE(bx,by);
19769
19770 if(!isCuttableType(type))
19771 {
19772 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
19773 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
19774
19775 // Layers
19776 for(int32_t i=0; i < 6; i++)
19777 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
19778 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
19779
19780 for(int32_t i=0; i<4; i++)
19781 if(tmpscr->door[i]==dBOMB && i==dir)
19782 switch(i)
19783 {
19784 case up:
19785 case down:
19786 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
19787
19788 break;
19789
19790 case left:
19791 case right:
19792 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
19793
19794 break;
19795 }
19796
19797 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
19798 }
19799
19800 1980088 }
19801
19802 9409 void HeroClass::fairycircle(int32_t type)
19803 {
19804
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 1169 times.
9409 if(fairyclk==0)
19805 {
19806
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1169 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1169 switch(type)
19807 {
19808 case REFILL_LIFE:
19809
2/2
✓ Branch 0 taken 1129 times.
✓ Branch 1 taken 40 times.
1169 if(didstuff&did_fairy) return;
19810
19811 40 didstuff|=did_fairy;
19812 40 break;
19813
19814 case REFILL_MAGIC:
19815 if(didstuff&did_magic) return;
19816
19817 didstuff|=did_magic;
19818 break;
19819
19820 case REFILL_ALL:
19821 if(didstuff&did_all) return;
19822
19823 didstuff|=did_all;
19824 }
19825
19826 40 refill_what=type;
19827 40 refill_why=REFILL_FAIRY;
19828 40 StartRefill(type);
19829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
19830 40 else {action=freeze; FFCore.setHeroAction(freeze);}
19831 40 holdclk=0;
19832 40 hopclk=0;
19833 40 }
19834
19835 8280 ++fairyclk;
19836
19837
2/2
✓ Branch 0 taken 5040 times.
✓ Branch 1 taken 3240 times.
8280 if(refilling!=REFILL_FAIRYDONE)
19838 {
19839
2/2
✓ Branch 0 taken 5000 times.
✓ Branch 1 taken 40 times.
5040 if(!refill())
19840 40 refilling=REFILL_FAIRYDONE;
19841 5040 }
19842
19843
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 40 times.
3240 else if(++holdclk>80)
19844 {
19845 40 reset_swordcharge();
19846 40 attackclk=0;
19847 40 action=none; FFCore.setHeroAction(none);
19848 40 fairyclk=0;
19849 40 holdclk=0;
19850 40 refill_why = 0;
19851 40 refilling=REFILL_NONE;
19852 40 map_bkgsfx(true);
19853 40 }
19854 9409 }
19855
19856 109981 int32_t touchcombo(int32_t x,int32_t y)
19857 {
19858
2/2
✓ Branch 0 taken 219962 times.
✓ Branch 1 taken 109981 times.
329943 for (int32_t i = 0; i <= 1; ++i)
19859 {
19860
2/2
✓ Branch 0 taken 189070 times.
✓ Branch 1 taken 30892 times.
219962 if(tmpscr2[i].valid!=0)
19861 {
19862
2/2
✓ Branch 0 taken 30768 times.
✓ Branch 1 taken 124 times.
30892 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19863 {
19864
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30768 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19865 30768 }
19866 else
19867 {
19868
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19869 }
19870 30892 }
19871 219962 }
19872
2/2
✓ Branch 0 taken 109976 times.
✓ Branch 1 taken 5 times.
109981 if (!_effectflag(x,y,1, -1)) return 0;
19873 109976 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
19874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109976 times.
109976 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19875 return 0;
19876
3/3
✓ Branch 0 taken 1523 times.
✓ Branch 1 taken 107527 times.
✓ Branch 2 taken 926 times.
109976 switch(cmb.type)
19877 {
19878 case cBSGRAVE:
19879 case cGRAVE:
19880
3/4
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 753 times.
✗ Branch 3 not taken.
1523 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
19881 {
19882 770 break;
19883 }
19884
19885 [[fallthrough]];
19886 case cARMOS:
19887 {
19888 1679 return cmb.type;
19889 }
19890 }
19891
19892 108297 return 0;
19893 109981 }
19894
19895 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
19896 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
19897
19898 static int32_t GridX(int32_t x)
19899 {
19900 return (x >> 4) << 4;
19901 }
19902
19903 //Snaps 'y' to the combo grid
19904 //Equivalent to calling ComboY(ComboAt(foo,y));
19905 static int32_t GridY(int32_t y)
19906 {
19907 return (y >> 4) << 4;
19908 }
19909
19910 int32_t grabComboFromPos(int32_t pos, int32_t type)
19911 {
19912 for(int32_t lyr = 6; lyr > -1; --lyr)
19913 {
19914 int32_t id = FFCore.tempScreens[lyr]->data[pos];
19915 if(combobuf[id].type == type)
19916 return id;
19917 }
19918 return -1;
19919 }
19920
19921 static int32_t typeMap[176];
19922 static int32_t istrig[176];
19923 static const int32_t SPTYPE_SOLID = -1;
19924 #define SP_VISITED 0x1
19925 #define SPFLAG(dir) (0x2<<dir)
19926 #define BEAM_AGE_LIMIT 32
19927 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
19928 {
19929 int32_t trigflag = set ? (1 << (set-1)) : ~0;
19930 if(spotdir > 3) return; //invalid dir
19931 bool doAge = true;
19932 byte f = 0;
19933 while(unsigned(curpos) < 176)
19934 {
19935 bool block_light = false;
19936 f = SPFLAG(spotdir);
19937 if((grid[curpos] & f) != f)
19938 {
19939 grid[curpos] |= f;
19940 istrig[curpos] |= trigflag;
19941 doAge = false;
19942 age = 0;
19943 }
19944 switch(spotdir)
19945 {
19946 case up:
19947 curpos -= 0x10;
19948 break;
19949 case down:
19950 curpos += 0x10;
19951 break;
19952 case left:
19953 if(!(curpos%0x10))
19954 curpos = -1;
19955 else --curpos;
19956 break;
19957 case right:
19958 ++curpos;
19959 if(!(curpos%0x10))
19960 curpos = -1;
19961 break;
19962 }
19963 if(unsigned(curpos) >= 176) break;
19964 switch(typeMap[curpos])
19965 {
19966 case SPTYPE_SOLID: case cBLOCKALL:
19967 curpos = -1;
19968 break;
19969 }
19970 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
19971 curpos = -1;
19972 if(unsigned(curpos) >= 176) break;
19973
19974 f = SPFLAG(oppositeDir[spotdir]);
19975 if((grid[curpos] & f) != f)
19976 {
19977 grid[curpos] |= f;
19978 istrig[curpos] |= trigflag;
19979 doAge = false;
19980 age = 0;
19981 }
19982 if(doAge)
19983 {
19984 if(++age > BEAM_AGE_LIMIT)
19985 break;
19986 }
19987 else doAge = true;
19988
19989 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
19990 spotdir = dir;
19991 else switch(typeMap[curpos])
19992 {
19993 case cLIGHTTARGET:
19994 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
19995 return;
19996 case cMIRROR:
19997 spotdir = oppositeDir[spotdir];
19998 break;
19999 case cMIRRORSLASH:
20000 switch(spotdir)
20001 {
20002 case up:
20003 spotdir = right; break;
20004 case right:
20005 spotdir = up; break;
20006 case down:
20007 spotdir = left; break;
20008 case left:
20009 spotdir = down; break;
20010 }
20011 break;
20012 case cMIRRORBACKSLASH:
20013 switch(spotdir)
20014 {
20015 case up:
20016 spotdir = left; break;
20017 case left:
20018 spotdir = up; break;
20019 case down:
20020 spotdir = right; break;
20021 case right:
20022 spotdir = down; break;
20023 }
20024 break;
20025 case cMAGICPRISM:
20026 for(byte d = 0; d < 4; ++d)
20027 {
20028 if(d == oppositeDir[spotdir]) continue;
20029 handleBeam(grid, age, d, curpos, set, block, refl);
20030 }
20031 return;
20032 case cMAGICPRISM4:
20033 for(byte d = 0; d < 4; ++d)
20034 {
20035 handleBeam(grid, age, d, curpos, set, block, refl);
20036 }
20037 return;
20038 }
20039 }
20040 }
20041
20042 1981852 void HeroClass::handleSpotlights()
20043 {
20044 typedef byte spot_t;
20045 //Store each different tile/color as grids
20046 1981852 std::map<int32_t, spot_t*> maps;
20047
1/2
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
1981852 int32_t shieldid = getCurrentShield(false);
20048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981852 times.
1981852 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
20049
2/4
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1981852 times.
1981852 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
20050
3/6
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981852 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1981852 times.
✗ Branch 5 not taken.
1981852 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
20051 1981852 memset(istrig, 0, sizeof(istrig));
20052
1/2
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
1981852 clear_bitmap(lightbeam_bmp);
20053
20054
2/2
✓ Branch 0 taken 348805952 times.
✓ Branch 1 taken 1981852 times.
350787804 for(size_t pos = 0; pos < 176; ++pos)
20055 {
20056 348805952 typeMap[pos] = 0;
20057
2/2
✓ Branch 0 taken 348805952 times.
✓ Branch 1 taken 2441641664 times.
2790447616 for(int32_t lyr = 6; lyr > -1; --lyr)
20058 {
20059 2441641664 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
20060
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2441641664 times.
✗ Branch 2 not taken.
2441641664 switch(cmb->type)
20061 {
20062 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
20063 case cMAGICPRISM: case cMAGICPRISM4:
20064 case cBLOCKALL: case cLIGHTTARGET:
20065 typeMap[pos] = cmb->type;
20066 break;
20067 case cGLASS:
20068 typeMap[pos] = 0;
20069 break;
20070 default:
20071 {
20072
4/4
✓ Branch 0 taken 1046417856 times.
✓ Branch 1 taken 1395223808 times.
✓ Branch 2 taken 833630296 times.
✓ Branch 3 taken 212787560 times.
2441641664 if(lyr < 3 && (cmb->walk & 0xF))
20073 {
20074 212787560 typeMap[pos] = SPTYPE_SOLID;
20075 212787560 }
20076 2441641664 continue; //next layer
20077 }
20078 }
20079 break; //hit a combo type
20080 }
20081 348805952 }
20082
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 1981746 times.
1981852 if(unsigned(heropos) < 176)
20083 {
20084
2/2
✓ Branch 0 taken 159911 times.
✓ Branch 1 taken 1821835 times.
1981746 switch(typeMap[heropos])
20085 {
20086 case SPTYPE_SOLID: case cBLOCKALL:
20087 159911 heropos = -1; //Blocked from hitting player
20088 159911 }
20089 1981746 }
20090
20091
2/2
✓ Branch 0 taken 13872964 times.
✓ Branch 1 taken 1981852 times.
15854816 for(size_t layer = 0; layer < 7; ++layer)
20092 {
20093 13872964 mapscr* curlayer = FFCore.tempScreens[layer];
20094
2/2
✓ Branch 0 taken 2441641664 times.
✓ Branch 1 taken 13872964 times.
2455514628 for(size_t pos = 0; pos < 176; ++pos)
20095 {
20096 //For each spotlight combo on each layer...
20097 2441641664 newcombo const& cmb = combobuf[curlayer->data[pos]];
20098
1/2
✓ Branch 0 taken 2441641664 times.
✗ Branch 1 not taken.
2441641664 if(cmb.type == cSPOTLIGHT)
20099 {
20100 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
20101 int32_t id = (cmb.usrflags&cflag1)
20102 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
20103 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
20104 if(!id) continue;
20105 // zprint2("ID = %ld\n", id);
20106 //Get the grid array for this tile/color
20107 spot_t* grid;
20108 if(maps[id])
20109 grid = maps[id];
20110 else
20111 {
20112 grid = new spot_t[176];
20113 memset(grid, 0, sizeof(spot_t)*176);
20114 maps[id] = grid;
20115 }
20116 byte spotdir = cmb.attribytes[0];
20117 int32_t curpos = pos;
20118 if(spotdir > 3)
20119 {
20120 grid[curpos] |= SP_VISITED;
20121 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
20122 }
20123 if(refl && curpos == heropos)
20124 {
20125 spotdir = dir;
20126 }
20127 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
20128 }
20129 2441641664 }
20130 13872964 }
20131
20132 //Draw visuals
20133
2/4
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1981852 times.
1981852 for(auto it = maps.begin(); it != maps.end();)
20134 {
20135 int32_t id = it->first;
20136 spot_t* grid = it->second;
20137 //
20138 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
20139 int32_t tile = (id&0xFFFFFF);
20140 int32_t cs = (id>>24);
20141 byte c_inner = ((-id)&0x0000FF);
20142 byte c_middle = ((-id)&0x00FF00)>>8;
20143 byte c_outter = ((-id)&0xFF0000)>>16;
20144 //{ Setup color bitmap
20145 BITMAP* cbmp = NULL;
20146 if(id < 0)
20147 {
20148 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
20149 cbmp = create_bitmap_ex(8, 16*t_max, 16);
20150 clear_bitmap(cbmp);
20151 for(size_t q = 1; q < t_max; ++q)
20152 {
20153 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
20154 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
20155 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
20156 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
20157 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
20158 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
20159 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
20160 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
20161 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
20162 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
20163 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
20164 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
20165 }
20166 //t_gr
20167 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
20168 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
20169 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
20170 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
20171 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
20172 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
20173 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
20174 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
20175 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
20176 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
20177 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
20178 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
20179 //t_up
20180 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
20181 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
20182 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
20183 //t_down
20184 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
20185 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
20186 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
20187 //t_left
20188 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
20189 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
20190 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
20191 //t_right
20192 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
20193 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
20194 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
20195 //t_uleft
20196 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
20197 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
20198 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
20199 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
20200 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
20201 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
20202 //t_uright
20203 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
20204 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
20205 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
20206 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
20207 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
20208 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
20209 //t_dleft
20210 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
20211 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
20212 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
20213 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
20214 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
20215 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
20216 //t_dright
20217 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
20218 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
20219 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
20220 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
20221 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
20222 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
20223 //t_vert
20224 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
20225 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
20226 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
20227 //t_horz
20228 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
20229 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
20230 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
20231 //t_notup
20232 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
20233 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
20234 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
20235 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
20236 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
20237 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
20238 //t_notdown
20239 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
20240 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
20241 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
20242 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
20243 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
20244 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
20245 //t_notleft
20246 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
20247 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
20248 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
20249 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
20250 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
20251 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
20252 //t_notright
20253 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
20254 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
20255 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
20256 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
20257 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
20258 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
20259 //t_all
20260 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
20261 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
20262 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
20263 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
20264 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
20265 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
20266 }
20267 //}
20268 //
20269 for(size_t pos = 0; pos < 176; ++pos)
20270 {
20271 int32_t offs = -1;
20272 switch(grid[pos]>>1)
20273 {
20274 case 0: default:
20275 if(grid[pos])
20276 {
20277 offs = t_gr;
20278 break;
20279 }
20280 continue; //no draw this pos
20281 case 0b0001:
20282 offs = t_up;
20283 break;
20284 case 0b0010:
20285 offs = t_down;
20286 break;
20287 case 0b0100:
20288 offs = t_left;
20289 break;
20290 case 0b1000:
20291 offs = t_right;
20292 break;
20293 case 0b0011:
20294 offs = t_vert;
20295 break;
20296 case 0b1100:
20297 offs = t_horz;
20298 break;
20299 case 0b0101:
20300 offs = t_uleft;
20301 break;
20302 case 0b1001:
20303 offs = t_uright;
20304 break;
20305 case 0b0110:
20306 offs = t_dleft;
20307 break;
20308 case 0b1010:
20309 offs = t_dright;
20310 break;
20311 case 0b1110:
20312 offs = t_notup;
20313 break;
20314 case 0b1101:
20315 offs = t_notdown;
20316 break;
20317 case 0b1011:
20318 offs = t_notleft;
20319 break;
20320 case 0b0111:
20321 offs = t_notright;
20322 break;
20323 case 0b1111:
20324 offs = t_all;
20325 break;
20326 }
20327 if(id > 0) //tile
20328 {
20329 //Draw 'tile' at 'pos'
20330 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
20331 }
20332 else //colors
20333 {
20334 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
20335 }
20336 }
20337 //
20338 if(cbmp) destroy_bitmap(cbmp);
20339 delete[] it->second;
20340 it = maps.erase(it);
20341 }
20342 //Check triggers
20343 1981852 bool hastrigs = false, istrigged = true;
20344
1/2
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
1981852 bool alltrig = getmapflag(mLIGHTBEAM);
20345
2/2
✓ Branch 0 taken 1981852 times.
✓ Branch 1 taken 13872964 times.
15854816 for(size_t layer = 0; layer < 7; ++layer)
20346 {
20347 13872964 mapscr* curlayer = FFCore.tempScreens[layer];
20348
2/2
✓ Branch 0 taken 2441641664 times.
✓ Branch 1 taken 13872964 times.
2455514628 for(size_t pos = 0; pos < 176; ++pos)
20349 {
20350 2441641664 newcombo const* cmb = &combobuf[curlayer->data[pos]];
20351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441641664 times.
2441641664 if(cmb->type == cLIGHTTARGET)
20352 {
20353 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20354 hastrigs = true;
20355 bool trigged = (istrig[pos]&trigflag);
20356 if(cmb->usrflags&cflag2) //Invert
20357 trigged = !trigged;
20358 if(cmb->usrflags&cflag1) //Solved Version
20359 {
20360 if(!(alltrig || trigged)) //Revert
20361 {
20362 curlayer->data[pos] -= 1;
20363 istrigged = false;
20364 }
20365 }
20366 else //Unsolved version
20367 {
20368 if(alltrig || trigged) //Light
20369 curlayer->data[pos] += 1;
20370 else istrigged = false;
20371 }
20372 }
20373
1/2
✓ Branch 0 taken 2441641664 times.
✗ Branch 1 not taken.
2441641664 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20374 {
20375 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20376 bool trigged = (istrig[pos]&trigflag);
20377 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20378 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20379 {
20380 do_trigger_combo(layer, pos);
20381 }
20382 }
20383 2441641664 }
20384 13872964 }
20385
1/2
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
1981852 word c = tmpscr->numFFC();
20386
2/2
✓ Branch 0 taken 1981852 times.
✓ Branch 1 taken 63264404 times.
65246256 for(word i=0; i<c; i++)
20387 {
20388 63264404 ffcdata& ffc = tmpscr->ffcs[i];
20389
1/2
✓ Branch 0 taken 63264404 times.
✗ Branch 1 not taken.
63264404 newcombo const* cmb = &combobuf[ffc.getData()];
20390
7/14
✓ Branch 0 taken 63264404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63264404 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63264404 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 63264404 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63264404 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 63264404 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 63264404 times.
✗ Branch 13 not taken.
63264404 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
20391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63264404 times.
63264404 if(cmb->type == cLIGHTTARGET)
20392 {
20393 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20394 hastrigs = true;
20395 bool trigged = (istrig[pos]&trigflag);
20396 if(cmb->usrflags&cflag2) //Invert
20397 trigged = !trigged;
20398 if(cmb->usrflags&cflag1) //Solved Version
20399 {
20400 if(!(alltrig || trigged)) //Revert
20401 {
20402 ffc.incData(-1);
20403 istrigged = false;
20404 }
20405 }
20406 else //Unsolved version
20407 {
20408 if(alltrig || trigged) //Light
20409 ffc.incData(1);
20410 else istrigged = false;
20411 }
20412 }
20413
1/2
✓ Branch 0 taken 63264404 times.
✗ Branch 1 not taken.
63264404 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20414 {
20415 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20416 bool trigged = (istrig[pos]&trigflag);
20417 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20418 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20419 {
20420 do_trigger_combo_ffc(i);
20421 }
20422 }
20423 63264404 }
20424
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1981852 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1981852 if(hastrigs && istrigged && !alltrig)
20425 {
20426 hidden_entrance(0,true,false,-7);
20427 sfx(tmpscr->secretsfx);
20428 if(!(tmpscr->flags5&fTEMPSECRETS))
20429 {
20430 setmapflag(mSECRET);
20431 setmapflag(mLIGHTBEAM);
20432 }
20433 }
20434 1981852 }
20435
20436 1980088 void HeroClass::checktouchblk()
20437 {
20438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1980088 times.
1980088 if(toogam) return;
20439
20440
2/2
✓ Branch 0 taken 70313 times.
✓ Branch 1 taken 1909775 times.
1980088 if(!pushing)
20441 1909775 return;
20442
20443 70313 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
20444
20445
2/4
✓ Branch 0 taken 70313 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70313 times.
70313 if(charging > 0 || spins > 0) //if not I probably will at some point...
20446 {
20447 if(Up()&&Left())tdir = (charging%2)*2;
20448 else if(Up()&&Right())tdir = (charging%2)*3;
20449 else if(Down()&&Left())tdir = 1+(charging%2)*1;
20450 else if(Down()&&Right())tdir = 1+(charging%2)*2;
20451 else
20452 {
20453 if(Up())tdir=0;
20454 else if(Down())tdir=1;
20455 else if(Left())tdir=2;
20456 else if(Right())tdir=3;
20457 }
20458 }
20459
20460 70313 int32_t tx=0,ty=-1;
20461
20462
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 20928 times.
✓ Branch 2 taken 19768 times.
✓ Branch 3 taken 13202 times.
✓ Branch 4 taken 16415 times.
70313 switch(tdir)
20463 {
20464 case up:
20465
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 20905 times.
20928 if(touchcombo(x,y+(bigHitbox?0:7)))
20466 {
20467 23 tx=x;
20468 23 ty=y+(bigHitbox?0:7);
20469 23 }
20470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20905 times.
20905 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
20471 {
20472 tx=x+8;
20473 ty=y+(bigHitbox?0:7);
20474 }
20475
20476 20928 break;
20477
20478 case down:
20479
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 18763 times.
19768 if(touchcombo(x,y+16))
20480 {
20481 1005 tx=x;
20482 1005 ty=y+16;
20483 1005 }
20484
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 18598 times.
18763 else if(touchcombo(x+8,y+16))
20485 {
20486 165 tx=x+8;
20487 165 ty=y+16;
20488 165 }
20489
20490 19768 break;
20491
20492 case left:
20493
2/2
✓ Branch 0 taken 13021 times.
✓ Branch 1 taken 181 times.
13202 if(touchcombo(x-1,y+15))
20494 {
20495 181 tx=x-1;
20496 181 ty=y+15;
20497 181 }
20498
20499 13202 break;
20500
20501 case right:
20502
2/2
✓ Branch 0 taken 16110 times.
✓ Branch 1 taken 305 times.
16415 if(touchcombo(x+16,y+15))
20503 {
20504 305 tx=x+16;
20505 305 ty=y+15;
20506 305 }
20507
20508 16415 break;
20509 }
20510
20511
2/2
✓ Branch 0 taken 68634 times.
✓ Branch 1 taken 1679 times.
70313 if(ty>=0)
20512 {
20513 1679 ty&=0xF0;
20514 1679 tx&=0xF0;
20515 1679 int32_t di = ty+(tx>>4);
20516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1679 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1679 if((getAction() != hopping || isSideViewHero()))
20517 {
20518 1679 trigger_armos_grave(0, di, dir);
20519 1679 }
20520 1679 }
20521 1980088 }
20522
20523 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
20524 {
20525 switch(cdir)
20526 {
20527 case up:
20528 cy-=16;
20529 break;
20530
20531 case down:
20532 cy+=16;
20533 break;
20534
20535 case left:
20536 cx-=16;
20537 break;
20538
20539 case right:
20540 cx+=16;
20541 break;
20542 }
20543
20544 // off the screen
20545 if(cx<0 || cy<0 || cx>255 || cy>175)
20546 {
20547 int32_t ns = nextscr(cdir);
20548
20549 if(ns==0xFFFF) return 0;
20550
20551 // want actual screen index, not game->maps[] index
20552 ns = (ns&127) + (ns>>7)*MAPSCRS;
20553
20554 switch(cdir)
20555 {
20556 case up:
20557 cy=160;
20558 break;
20559
20560 case down:
20561 cy=0;
20562 break;
20563
20564 case left:
20565 cx=240;
20566 break;
20567
20568 case right:
20569 cx=0;
20570 break;
20571 }
20572
20573 // from MAPCOMBO()
20574 int32_t cmb = (cy&0xF0)+(cx>>4);
20575
20576 if(cmb>175)
20577 return 0;
20578
20579 return TheMaps[ns].data[cmb]; // entire combo code
20580 }
20581
20582 return MAPCOMBO(cx,cy);
20583 }
20584
20585 809 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
20586 {
20587
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 197 times.
✓ Branch 4 taken 261 times.
809 switch(cdir)
20588 {
20589 case up:
20590 146 cy-=16;
20591 146 break;
20592
20593 case down:
20594 205 cy+=16;
20595 205 break;
20596
20597 case left:
20598 197 cx-=16;
20599 197 break;
20600
20601 case right:
20602 261 cx+=16;
20603 261 break;
20604 }
20605
20606 // off the screen
20607
8/8
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 790 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 782 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 772 times.
809 if(cx<0 || cy<0 || cx>255 || cy>175)
20608 {
20609 37 int32_t ns = nextscr(cdir);
20610
20611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(ns==0xFFFF) return 0;
20612
20613 // want actual screen index, not game->maps[] index
20614 37 ns = (ns&127) + (ns>>7)*MAPSCRS;
20615
20616
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 8 times.
37 switch(cdir)
20617 {
20618 case up:
20619 16 cy=160;
20620 16 break;
20621
20622 case down:
20623 10 cy=0;
20624 10 break;
20625
20626 case left:
20627 3 cx=240;
20628 3 break;
20629
20630 case right:
20631 8 cx=0;
20632 8 break;
20633 }
20634
20635 // from MAPCOMBO()
20636 37 int32_t cmb = (cy&0xF0)+(cx>>4);
20637
20638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(cmb>175)
20639 return 0;
20640
20641
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 30 times.
37 if(!comboflag)
20642 {
20643 30 return TheMaps[ns].sflag[cmb]; // flag
20644 }
20645 else
20646 {
20647 7 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
20648 }
20649 }
20650
20651
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 602 times.
772 if(comboflag)
20652 {
20653 170 return MAPCOMBOFLAG(cx,cy);
20654 }
20655
20656 602 return MAPFLAG(cx,cy);
20657 809 }
20658
20659 bool did_secret;
20660
20661 1980088 void HeroClass::checkspecial()
20662 {
20663 1980088 checktouchblk();
20664
20665 1980088 bool hasmainguy = hasMainGuy(); // calculate it once
20666
20667
4/4
✓ Branch 0 taken 1955986 times.
✓ Branch 1 taken 24102 times.
✓ Branch 2 taken 1497491 times.
✓ Branch 3 taken 458495 times.
1980088 if(!(loaded_enemies && !hasmainguy))
20668 1521593 did_secret=false;
20669 else
20670 {
20671 // after beating enemies
20672
20673 // item
20674
2/2
✓ Branch 0 taken 458299 times.
✓ Branch 1 taken 196 times.
458495 if(hasitem&(4|2|1))
20675 {
20676 196 int32_t Item=tmpscr->item;
20677
20678 //if(getmapflag())
20679 // Item=0;
20680
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20681 {
20682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(hasitem==1)
20683 196 sfx(WAV_CLEARED);
20684
20685
2/4
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
392 items.add(new item((zfix)tmpscr->itemx,
20686
6/12
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 196 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 196 times.
✗ Branch 11 not taken.
196 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20687
6/10
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 184 times.
✗ Branch 9 not taken.
196 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20689 196 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20690 196 }
20691
20692 196 hasitem &= ~ (4|2|1);
20693 196 }
20694
20695 // generic 'Enemies->' trigger
20696
2/2
✓ Branch 0 taken 3209465 times.
✓ Branch 1 taken 458495 times.
3667960 for(auto lyr = 0; lyr < 7; ++lyr)
20697 {
20698
2/2
✓ Branch 0 taken 564865840 times.
✓ Branch 1 taken 3209465 times.
568075305 for(auto pos = 0; pos < 176; ++pos)
20699 {
20700 564865840 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
20701
1/2
✓ Branch 0 taken 564865840 times.
✗ Branch 1 not taken.
564865840 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20702 {
20703 do_trigger_combo(lyr,pos);
20704 }
20705 564865840 }
20706 3209465 }
20707 458495 word c = tmpscr->numFFC();
20708
2/2
✓ Branch 0 taken 14578170 times.
✓ Branch 1 taken 458495 times.
15036665 for(word i=0; i<c; i++)
20709 {
20710 14578170 ffcdata& ffc = tmpscr->ffcs[i];
20711 14578170 newcombo const& cmb = combobuf[ffc.getData()];
20712
1/2
✓ Branch 0 taken 14578170 times.
✗ Branch 1 not taken.
14578170 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20713 {
20714 do_trigger_combo_ffc(i);
20715 }
20716 14578170 }
20717
1/2
✓ Branch 0 taken 458495 times.
✗ Branch 1 not taken.
458495 if(tmpscr->flags9 & fENEMY_WAVES)
20718 {
20719 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
20720 }
20721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 458495 times.
458495 if(!hasmainguy)
20722 {
20723 // if room has traps, guys don't come back
20724
2/2
✓ Branch 0 taken 234749440 times.
✓ Branch 1 taken 458495 times.
235207935 for(int32_t i=0; i<eMAXGUYS; i++)
20725 {
20726
4/4
✓ Branch 0 taken 6877425 times.
✓ Branch 1 taken 227872015 times.
✓ Branch 2 taken 916990 times.
✓ Branch 3 taken 5960435 times.
234749440 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
20727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 916990 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
916990 if(guys.idCount(i) && !getmapflag(mTMPNORET))
20728 setmapflag(mTMPNORET);
20729 234749440 }
20730 // clear enemies and open secret
20731
4/4
✓ Branch 0 taken 410889 times.
✓ Branch 1 taken 47606 times.
✓ Branch 2 taken 410686 times.
✓ Branch 3 taken 203 times.
458495 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
20732 {
20733 203 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
20734 203 hidden_entrance(0,true,only16_31,-2);
20735
20736
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
203 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
20737 {
20738 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
20739 }
20740
20741 203 sfx(tmpscr->secretsfx);
20742 203 did_secret=true;
20743 203 }
20744 458495 }
20745 }
20746
20747 // doors
20748
2/2
✓ Branch 0 taken 1319298 times.
✓ Branch 1 taken 6834956 times.
8154254 for(int32_t i=0; i<4; i++)
20749
2/2
✓ Branch 0 taken 6174166 times.
✓ Branch 1 taken 660790 times.
6834956 if(tmpscr->door[i]==dSHUTTER)
20750 {
20751
4/4
✓ Branch 0 taken 650568 times.
✓ Branch 1 taken 10222 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 650226 times.
660790 if(opendoors==0 && loaded_enemies)
20752 {
20753
4/4
✓ Branch 0 taken 571146 times.
✓ Branch 1 taken 79080 times.
✓ Branch 2 taken 570500 times.
✓ Branch 3 taken 646 times.
650226 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
20754 646 opendoors=12;
20755 650226 }
20756
2/2
✓ Branch 0 taken 8474 times.
✓ Branch 1 taken 2090 times.
10564 else if(opendoors<0)
20757 2090 ++opendoors;
20758
2/2
✓ Branch 0 taken 7780 times.
✓ Branch 1 taken 694 times.
8474 else if((--opendoors)==0)
20759 694 openshutters();
20760
20761 660790 break;
20762 }
20763
20764 // set boss flag when boss is gone
20765
6/6
✓ Branch 0 taken 1955986 times.
✓ Branch 1 taken 24102 times.
✓ Branch 2 taken 30613 times.
✓ Branch 3 taken 1925373 times.
✓ Branch 4 taken 22976 times.
✓ Branch 5 taken 7637 times.
1980088 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
20766 {
20767 7637 game->lvlitems[dlevel]|=liBOSS;
20768 7637 stop_sfx(tmpscr->bosssfx);
20769 7637 }
20770
20771
1/2
✓ Branch 0 taken 1980088 times.
✗ Branch 1 not taken.
1980088 if(getmapflag(mCHEST)) // if special stuff done before
20772 {
20773 remove_chests((currscr>=128)?1:0);
20774 }
20775
20776
1/2
✓ Branch 0 taken 1980088 times.
✗ Branch 1 not taken.
1980088 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
20777 {
20778 remove_lockedchests((currscr>=128)?1:0);
20779 }
20780
20781
1/2
✓ Branch 0 taken 1980088 times.
✗ Branch 1 not taken.
1980088 if(getmapflag(mBOSSCHEST)) // if special stuff done before
20782 {
20783 remove_bosschests((currscr>=128)?1:0);
20784 }
20785
20786 1980088 clear_xstatecombos((currscr>=128)?1:0);
20787
20788
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1980088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1980088 if((hasitem&8) && triggered_screen_secrets)
20789 {
20790 int32_t Item=tmpscr->item;
20791
20792 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20793 {
20794 items.add(new item((zfix)tmpscr->itemx,
20795 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20796 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20797 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20798 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20799 }
20800
20801 hasitem &= ~8;
20802 }
20803 1980088 }
20804
20805 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
20806 940350 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
20807 {
20808 int32_t tmp;
20809 940350 poses[0] = COMBOPOS(x1,y1);
20810
20811 940350 tmp = COMBOPOS(x1,y2);
20812
2/2
✓ Branch 0 taken 741440 times.
✓ Branch 1 taken 198910 times.
940350 if(tmp == poses[0])
20813 741440 poses[1] = -1;
20814 198910 else poses[1] = tmp;
20815
20816 940350 tmp = COMBOPOS(x2,y1);
20817
3/4
✓ Branch 0 taken 393438 times.
✓ Branch 1 taken 546912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 393438 times.
940350 if(tmp == poses[0] || tmp == poses[1])
20818 546912 poses[2] = -1;
20819 393438 else poses[2] = tmp;
20820
20821 940350 tmp = COMBOPOS(x2,y2);
20822
6/6
✓ Branch 0 taken 509661 times.
✓ Branch 1 taken 430689 times.
✓ Branch 2 taken 393438 times.
✓ Branch 3 taken 116223 times.
✓ Branch 4 taken 310751 times.
✓ Branch 5 taken 82687 times.
940350 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
20823 857663 poses[3] = -1;
20824 82687 else poses[3] = tmp;
20825 940350 }
20826
20827 1980088 void HeroClass::checkspecial2(int32_t *ls)
20828 {
20829
4/6
✓ Branch 0 taken 1970739 times.
✓ Branch 1 taken 9349 times.
✓ Branch 2 taken 1970739 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1970739 times.
1980088 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
20830 {
20831
2/2
✓ Branch 0 taken 605453 times.
✓ Branch 1 taken 1365286 times.
1970739 if(y.getInt()&7)
20832 605453 return;
20833
20834
2/2
✓ Branch 0 taken 834673 times.
✓ Branch 1 taken 530613 times.
1365286 if(x.getInt()&7)
20835 834673 return;
20836 530613 }
20837
20838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 539962 times.
539962 if(toogam) return;
20839
20840 539962 bool didstrig = false;
20841
20842
2/2
✓ Branch 0 taken 1079924 times.
✓ Branch 1 taken 539962 times.
1619886 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
20843 {
20844
4/4
✓ Branch 0 taken 2159848 times.
✓ Branch 1 taken 1079924 times.
✓ Branch 2 taken 4319696 times.
✓ Branch 3 taken 2159848 times.
7559468 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
20845 {
20846
2/2
✓ Branch 0 taken 2159848 times.
✓ Branch 1 taken 2159848 times.
4319696 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
20847 4319696 int32_t stype = cmb.type;
20848 4319696 int32_t warpsound = cmb.attribytes[0];
20849
1/2
✓ Branch 0 taken 4319696 times.
✗ Branch 1 not taken.
4319696 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
20850 stype = cNONE;
20851
1/2
✓ Branch 0 taken 4319696 times.
✗ Branch 1 not taken.
4319696 if(stype==cSWARPA)
20852 {
20853 if(tmpscr->flags5&fDIRECTSWARP)
20854 {
20855 didpit=true;
20856 pitx=x;
20857 pity=y;
20858 }
20859
20860 sdir=dir;
20861 dowarp(0,0,warpsound);
20862 return;
20863 }
20864
20865
1/2
✓ Branch 0 taken 4319696 times.
✗ Branch 1 not taken.
4319696 if(stype==cSWARPB)
20866 {
20867 if(tmpscr->flags5&fDIRECTSWARP)
20868 {
20869 didpit=true;
20870 pitx=x;
20871 pity=y;
20872 }
20873
20874 sdir=dir;
20875 dowarp(0,1,warpsound);
20876 return;
20877 }
20878
20879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4319696 times.
4319696 if(stype==cSWARPC)
20880 {
20881 if(tmpscr->flags5&fDIRECTSWARP)
20882 {
20883 didpit=true;
20884 pitx=x;
20885 pity=y;
20886 }
20887
20888 sdir=dir;
20889 dowarp(0,2,warpsound);
20890 return;
20891 }
20892
20893
1/2
✓ Branch 0 taken 4319696 times.
✗ Branch 1 not taken.
4319696 if(stype==cSWARPD)
20894 {
20895 if(tmpscr->flags5&fDIRECTSWARP)
20896 {
20897 didpit=true;
20898 pitx=x;
20899 pity=y;
20900 }
20901
20902 sdir=dir;
20903 dowarp(0,3,warpsound);
20904 return;
20905 }
20906
20907
1/2
✓ Branch 0 taken 4319696 times.
✗ Branch 1 not taken.
4319696 if(stype==cSWARPR)
20908 {
20909 if(tmpscr->flags5&fDIRECTSWARP)
20910 {
20911 didpit=true;
20912 pitx=x;
20913 pity=y;
20914 }
20915
20916 sdir=dir;
20917 dowarp(0,(zc_oldrand()%4),warpsound);
20918 return;
20919 }
20920
20921
5/6
✓ Branch 0 taken 4319666 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4319666 times.
✓ Branch 4 taken 4319666 times.
✓ Branch 5 taken 30 times.
4319696 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=MAPCOMBO(x+j,y+i))
20922 {
20923 // zprint("Step Secs\n");
20924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if(stype==cSTRIGFLAG && canPermSecret())
20925 {
20926 if(!didstrig)
20927 {
20928 stepsecret = ((int32_t)(y+i)&0xF0)+((int32_t)(x+j)>>4);
20929
20930 if(!(tmpscr->flags5&fTEMPSECRETS))
20931 {
20932 setmapflag(mSECRET);
20933 }
20934 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
20935 //zprint("Step Secrets SFX: %d\n", thesfx);
20936 sfx(warpsound,pan((int32_t)x));
20937 hidden_entrance(0,true,false);
20938 didstrig = true;
20939 }
20940 }
20941 else
20942 {
20943
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 13 times.
30 if(!didstrig)
20944 {
20945 13 stepsecret = ((int32_t)(y+i)&0xF0)+((int32_t)(x+j)>>4);
20946 13 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
20947 13 hidden_entrance(0,true,only16_31);
20948 13 didstrig = true;
20949 //play trigger sound
20950 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
20951 //zprint("Step Secrets SFX: %d\n", thesfx);
20952 //sfx(thesfx,pan((int32_t)x));
20953 13 sfx(warpsound,pan((int32_t)x));
20954 13 }
20955 }
20956 30 }
20957 6479544 }
20958 1079924 }
20959
20960 539962 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
20961
20962 // check if he's standing on a warp he just came out of
20963 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
20964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 539962 times.
539962 if (!get_bit(quest_rules,qr_210_WARPRETURN))
20965 {
20966
6/6
✓ Branch 0 taken 539172 times.
✓ Branch 1 taken 790 times.
✓ Branch 2 taken 65025 times.
✓ Branch 3 taken 474147 times.
✓ Branch 4 taken 2464 times.
✓ Branch 5 taken 62561 times.
539962 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
20967 {
20968
5/6
✓ Branch 0 taken 62171 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 61547 times.
✓ Branch 3 taken 624 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61547 times.
62561 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
20969 {
20970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61547 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61547 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
20971 61547 else return;
20972 }
20973 1014 }
20974 478415 }
20975 else
20976 {
20977 if((int(y)&0xF8)==warpy)
20978 {
20979 if(x==warpx)
20980 {
20981 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
20982 else return;
20983 }
20984 }
20985 }
20986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478415 times.
478415 if (!RaftPass) warpy=-1;
20987
20988
6/6
✓ Branch 0 taken 477133 times.
✓ Branch 1 taken 1282 times.
✓ Branch 2 taken 26341 times.
✓ Branch 3 taken 450792 times.
✓ Branch 4 taken 23884 times.
✓ Branch 5 taken 2457 times.
478415 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
20989 {
20990 454531 raftwarpy = -1;
20991 454531 }
20992
6/6
✓ Branch 0 taken 477550 times.
✓ Branch 1 taken 865 times.
✓ Branch 2 taken 26683 times.
✓ Branch 3 taken 450867 times.
✓ Branch 4 taken 25133 times.
✓ Branch 5 taken 1550 times.
478415 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
20993 {
20994 453282 raftwarpx = -1;
20995 453282 }
20996 478415 int32_t tx=x;
20997 478415 int32_t ty=y;
20998
20999 478415 int32_t flag=0;
21000 478415 int32_t flag2=0;
21001 478415 int32_t flag3=0;
21002 478415 int32_t type=0;
21003 478415 int32_t water=0;
21004 478415 int32_t index = 0;
21005
21006 478415 bool setsave=false;
21007 478415 int32_t warpsfx2 = 0;
21008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478415 times.
478415 if (RaftPass) goto RaftingStuff;
21009
21010 //bool gotpit=false;
21011
21012 int32_t x1,x2,y1,y2;
21013 478415 x1 = tx;
21014 478415 x2 = tx+15;
21015 478415 y1 = ty;
21016 478415 y2 = ty+15;
21017
21018
3/4
✓ Branch 0 taken 469174 times.
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 469174 times.
478415 if((diagonalMovement||NO_GRIDLOCK))
21019 {
21020 9241 x1 = tx+4;
21021 9241 x2 = tx+11;
21022 9241 y1 = ty+4;
21023 9241 y2 = ty+11;
21024 9241 }
21025
21026 int32_t types[4];
21027 478415 types[0]=types[1]=types[2]=types[3]=-1;
21028 int32_t cids[4];
21029 int32_t ffcids[4];
21030 478415 cids[0]=cids[1]=cids[2]=cids[3]=-1;
21031 478415 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
21032 //
21033 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
21034 //
21035 478415 types[0] = MAPFLAG(x1,y1);
21036 478415 types[1] = MAPFLAG(x1,y2);
21037 478415 types[2] = MAPFLAG(x2,y1);
21038 478415 types[3] = MAPFLAG(x2,y2);
21039
21040
21041 //MAPFFCOMBO
21042
21043
21044
6/6
✓ Branch 0 taken 462008 times.
✓ Branch 1 taken 16407 times.
✓ Branch 2 taken 460571 times.
✓ Branch 3 taken 1437 times.
✓ Branch 4 taken 493 times.
✓ Branch 5 taken 460078 times.
478415 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21045 460078 flag = types[0];
21046
21047 // 2.10 compatibility...
21048
8/10
✓ Branch 0 taken 17818 times.
✓ Branch 1 taken 519 times.
✓ Branch 2 taken 15760 times.
✓ Branch 3 taken 2058 times.
✓ Branch 4 taken 7955 times.
✓ Branch 5 taken 7805 times.
✓ Branch 6 taken 7955 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7955 times.
18337 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
21049 7805 flag = types[0];
21050
21051
21052 478415 types[0] = MAPCOMBOFLAG(x1,y1);
21053 478415 types[1] = MAPCOMBOFLAG(x1,y2);
21054 478415 types[2] = MAPCOMBOFLAG(x2,y1);
21055 478415 types[3] = MAPCOMBOFLAG(x2,y2);
21056
21057
6/6
✓ Branch 0 taken 478062 times.
✓ Branch 1 taken 353 times.
✓ Branch 2 taken 478054 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 477954 times.
478415 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21058 477954 flag2 = types[0];
21059
21060 478415 types[0] = MAPFFCOMBOFLAG(x1,y1);
21061 478415 types[1] = MAPFFCOMBOFLAG(x1,y2);
21062 478415 types[2] = MAPFFCOMBOFLAG(x2,y1);
21063 478415 types[3] = MAPFFCOMBOFLAG(x2,y2);
21064
21065
21066 //
21067
21068
6/6
✓ Branch 0 taken 478410 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 478403 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 478402 times.
478415 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21069 478402 flag3 = types[0];
21070
21071 //
21072 // Now, let's check for warp combos...
21073 //
21074
21075 //
21076
21077 478415 cids[0] = MAPCOMBO(x1,y1);
21078 478415 cids[1] = MAPCOMBO(x1,y2);
21079 478415 cids[2] = MAPCOMBO(x2,y1);
21080 478415 cids[3] = MAPCOMBO(x2,y2);
21081
21082 478415 types[0] = COMBOTYPE(x1,y1);
21083
21084
2/2
✓ Branch 0 taken 477574 times.
✓ Branch 1 taken 841 times.
478415 if(MAPFFCOMBO(x1,y1))
21085 {
21086 841 types[0] = FFCOMBOTYPE(x1,y1);
21087 841 cids[0] = MAPFFCOMBO(x1,y1);
21088 841 }
21089
21090 478415 types[1] = COMBOTYPE(x1,y2);
21091
21092
2/2
✓ Branch 0 taken 477730 times.
✓ Branch 1 taken 685 times.
478415 if(MAPFFCOMBO(x1,y2))
21093 {
21094 685 types[1] = FFCOMBOTYPE(x1,y2);
21095 685 cids[1] = MAPFFCOMBO(x1,y2);
21096 685 }
21097
21098 478415 types[2] = COMBOTYPE(x2,y1);
21099
21100
2/2
✓ Branch 0 taken 477659 times.
✓ Branch 1 taken 756 times.
478415 if(MAPFFCOMBO(x2,y1))
21101 {
21102 756 types[2] = FFCOMBOTYPE(x2,y1);
21103 756 cids[2] = MAPFFCOMBO(x2,y1);
21104 756 }
21105 478415 types[3] = COMBOTYPE(x2,y2);
21106
21107
2/2
✓ Branch 0 taken 477909 times.
✓ Branch 1 taken 506 times.
478415 if(MAPFFCOMBO(x2,y2))
21108 {
21109 506 types[3] = FFCOMBOTYPE(x2,y2);
21110 506 cids[3] = MAPFFCOMBO(x2,y2);
21111 506 }
21112 // Change B, C and D warps into A, for the comparison below...
21113
2/2
✓ Branch 0 taken 1913660 times.
✓ Branch 1 taken 478415 times.
2392075 for(int32_t i=0; i<4; i++)
21114 {
21115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21116 {
21117 types[i] = cNONE;
21118 continue;
21119 }
21120
2/2
✓ Branch 0 taken 1063 times.
✓ Branch 1 taken 1912597 times.
1913660 if(types[i]==cCAVE)
21121 {
21122 1063 index=0;
21123 1063 warpsfx2 = combobuf[cids[i]].attribytes[0];
21124 1063 }
21125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1912597 times.
1912597 else if(types[i]==cCAVEB)
21126 {
21127 types[i]=cCAVE;
21128 index=1;
21129 warpsfx2 = combobuf[cids[i]].attribytes[0];
21130 }
21131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1912597 times.
1912597 else if(types[i]==cCAVEC)
21132 {
21133 types[i]=cCAVE;
21134 index=2;
21135 warpsfx2 = combobuf[cids[i]].attribytes[0];
21136 }
21137
1/2
✓ Branch 0 taken 1912597 times.
✗ Branch 1 not taken.
1912597 else if(types[i]==cCAVED)
21138 {
21139 types[i]=cCAVE;
21140 index=3;
21141 warpsfx2 = combobuf[cids[i]].attribytes[0];
21142 }
21143
21144
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 1913584 times.
1913660 if(types[i]==cPIT)
21145 {
21146 76 index=0;
21147 76 warpsfx2 = combobuf[cids[i]].attribytes[0];
21148 76 }
21149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913584 times.
1913584 else if(types[i]==cPITB)
21150 {
21151 types[i]=cPIT;
21152 warpsfx2 = combobuf[cids[i]].attribytes[0];
21153 index=1;
21154 }
21155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913584 times.
1913584 else if(types[i]==cPITC)
21156 {
21157 types[i]=cPIT;
21158 warpsfx2 = combobuf[cids[i]].attribytes[0];
21159 index=2;
21160 }
21161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913584 times.
1913584 else if(types[i]==cPITD)
21162 {
21163 types[i]=cPIT;
21164 warpsfx2 = combobuf[cids[i]].attribytes[0];
21165 index=3;
21166 }
21167
1/2
✓ Branch 0 taken 1913584 times.
✗ Branch 1 not taken.
1913584 else if(types[i]==cPITR)
21168 {
21169 types[i]=cPIT;
21170 warpsfx2 = combobuf[cids[i]].attribytes[0];
21171 index=zc_oldrand()%4;
21172 }
21173
21174
2/2
✓ Branch 0 taken 3486 times.
✓ Branch 1 taken 1910174 times.
1913660 if(types[i]==cSTAIR)
21175 {
21176 3486 index=0;
21177 3486 warpsfx2 = combobuf[cids[i]].attribytes[0];
21178 3486 }
21179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910174 times.
1910174 else if(types[i]==cSTAIRB)
21180 {
21181 types[i]=cSTAIR;
21182 warpsfx2 = combobuf[cids[i]].attribytes[0];
21183 index=1;
21184 }
21185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910174 times.
1910174 else if(types[i]==cSTAIRC)
21186 {
21187 types[i]=cSTAIR;
21188 warpsfx2 = combobuf[cids[i]].attribytes[0];
21189 index=2;
21190 }
21191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910174 times.
1910174 else if(types[i]==cSTAIRD)
21192 {
21193 types[i]=cSTAIR;
21194 warpsfx2 = combobuf[cids[i]].attribytes[0];
21195 index=3;
21196 }
21197
1/2
✓ Branch 0 taken 1910174 times.
✗ Branch 1 not taken.
1910174 else if(types[i]==cSTAIRR)
21198 {
21199 types[i]=cSTAIR;
21200 index=zc_oldrand()%4;
21201 warpsfx2 = combobuf[cids[i]].attribytes[0];
21202 }
21203
21204
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 1913603 times.
1913660 if(types[i]==cCAVE2)
21205 {
21206 57 index=0;
21207 57 warpsfx2 = combobuf[cids[i]].attribytes[0];
21208 57 }
21209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913603 times.
1913603 else if(types[i]==cCAVE2B)
21210 {
21211 types[i]=cCAVE2;
21212 index=1;
21213 warpsfx2 = combobuf[cids[i]].attribytes[0];
21214 }
21215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913603 times.
1913603 else if(types[i]==cCAVE2C)
21216 {
21217 types[i]=cCAVE2;
21218 warpsfx2 = combobuf[cids[i]].attribytes[0];
21219 index=2;
21220 }
21221
1/2
✓ Branch 0 taken 1913603 times.
✗ Branch 1 not taken.
1913603 else if(types[i]==cCAVE2D)
21222 {
21223 types[i]=cCAVE2;
21224 warpsfx2 = combobuf[cids[i]].attribytes[0];
21225 index=3;
21226 }
21227
21228
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1913654 times.
1913660 if(types[i]==cSWIMWARP)
21229 {
21230 6 index=0;
21231 6 warpsfx2 = combobuf[cids[i]].attribytes[0];
21232 6 }
21233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913654 times.
1913654 else if(types[i]==cSWIMWARPB)
21234 {
21235 types[i]=cSWIMWARP;
21236 warpsfx2 = combobuf[cids[i]].attribytes[0];
21237 index=1;
21238 }
21239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913654 times.
1913654 else if(types[i]==cSWIMWARPC)
21240 {
21241 types[i]=cSWIMWARP;
21242 warpsfx2 = combobuf[cids[i]].attribytes[0];
21243 index=2;
21244 }
21245
1/2
✓ Branch 0 taken 1913654 times.
✗ Branch 1 not taken.
1913654 else if(types[i]==cSWIMWARPD)
21246 {
21247 types[i]=cSWIMWARP;
21248 warpsfx2 = combobuf[cids[i]].attribytes[0];
21249 index=3;
21250 }
21251
21252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 if(types[i]==cDIVEWARP)
21253 {
21254 index=0;
21255 warpsfx2 = combobuf[cids[i]].attribytes[0];
21256 }
21257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 else if(types[i]==cDIVEWARPB)
21258 {
21259 types[i]=cDIVEWARP;
21260 warpsfx2 = combobuf[cids[i]].attribytes[0];
21261 index=1;
21262 }
21263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 else if(types[i]==cDIVEWARPC)
21264 {
21265 types[i]=cDIVEWARP;
21266 warpsfx2 = combobuf[cids[i]].attribytes[0];
21267 index=2;
21268 }
21269
1/2
✓ Branch 0 taken 1913660 times.
✗ Branch 1 not taken.
1913660 else if(types[i]==cDIVEWARPD)
21270 {
21271 types[i]=cDIVEWARP;
21272 warpsfx2 = combobuf[cids[i]].attribytes[0];
21273 index=3;
21274 }
21275
21276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
21277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
21278
1/2
✓ Branch 0 taken 1913660 times.
✗ Branch 1 not taken.
1913660 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
21279 1913660 }
21280
21281 // Special case for step combos; otherwise, they act oddly in some cases
21282
7/8
✓ Branch 0 taken 439352 times.
✓ Branch 1 taken 39063 times.
✓ Branch 2 taken 433834 times.
✓ Branch 3 taken 5518 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44581 times.
✓ Branch 6 taken 3992 times.
✓ Branch 7 taken 3992 times.
478415 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
21283 {
21284
6/8
✓ Branch 0 taken 422315 times.
✓ Branch 1 taken 7527 times.
✓ Branch 2 taken 422315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 171 times.
✓ Branch 5 taken 422144 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 171 times.
437826 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21285 422315 type = types[1];
21286 429842 }
21287
21288 //Generic Step
21289
6/8
✓ Branch 0 taken 470175 times.
✓ Branch 1 taken 8240 times.
✓ Branch 2 taken 470175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 171 times.
✓ Branch 5 taken 470004 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 171 times.
478415 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21290 {
21291 int32_t poses[4];
21292 int32_t sensPoses[4];
21293 470175 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
21294 470175 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
21295
3/4
✓ Branch 0 taken 460934 times.
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 460934 times.
470175 if(diagonalMovement||NO_GRIDLOCK)
21296 9241 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
21297 460934 else getPoses(poses, tx, ty, tx+15, ty+15);
21298 470175 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
21299 470175 bool hasStep[4] = {false};
21300
2/2
✓ Branch 0 taken 1880700 times.
✓ Branch 1 taken 470175 times.
2350875 for(auto p = 0; p < 4; ++p)
21301 {
21302
2/2
✓ Branch 0 taken 1880700 times.
✓ Branch 1 taken 13164900 times.
15045600 for(auto lyr = 0; lyr < 7; ++lyr)
21303 {
21304
2/2
✓ Branch 0 taken 6598179 times.
✓ Branch 1 taken 6566721 times.
13164900 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21305
3/4
✓ Branch 0 taken 6598179 times.
✓ Branch 1 taken 6566721 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13164900 times.
13164900 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
21306 13164900 || types[p] == cSTEP)
21307 {
21308 hasStep[p] = true;
21309 break;
21310 }
21311 13164900 }
21312 1880700 }
21313 470175 bool canNormalStep = true;
21314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 470175 times.
470175 for(auto p = 0; p < 4; ++p)
21315 {
21316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 470175 times.
470175 if(poses[p] < 0) continue;
21317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 470175 times.
470175 if(!hasStep[p])
21318 {
21319 470175 canNormalStep = false;
21320 470175 break;
21321 }
21322 }
21323
2/2
✓ Branch 0 taken 1880700 times.
✓ Branch 1 taken 470175 times.
2350875 for(auto p = 0; p < 4; ++p)
21324 {
21325
2/2
✓ Branch 0 taken 13164900 times.
✓ Branch 1 taken 1880700 times.
15045600 for(auto lyr = 0; lyr < 7; ++lyr)
21326 {
21327
2/2
✓ Branch 0 taken 6598179 times.
✓ Branch 1 taken 6566721 times.
13164900 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21328
2/2
✓ Branch 0 taken 4709516 times.
✓ Branch 1 taken 8455384 times.
13164900 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
21329
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13164900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13164900 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
21330 {
21331 do_trigger_combo(lyr,poses[p]);
21332 if(poses[p] == sensPoses[p]) continue;
21333 }
21334
3/4
✓ Branch 0 taken 4709516 times.
✓ Branch 1 taken 8455384 times.
✓ Branch 2 taken 4709516 times.
✗ Branch 3 not taken.
13164900 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
21335 {
21336 do_trigger_combo(lyr,sensPoses[p]);
21337 }
21338 13164900 }
21339 1880700 }
21340 470175 word c = tmpscr->numFFC();
21341
2/2
✓ Branch 0 taken 14896417 times.
✓ Branch 1 taken 470175 times.
15366592 for(word i=0; i<c; i++)
21342 {
21343 14896417 bool found = false;
21344
2/2
✓ Branch 0 taken 29792834 times.
✓ Branch 1 taken 14896417 times.
44689251 for(auto xch = 0; xch < 2; ++xch)
21345 {
21346
2/2
✓ Branch 0 taken 59585668 times.
✓ Branch 1 taken 29792834 times.
89378502 for(auto ych = 0; ych < 2; ++ych)
21347 {
21348
2/2
✓ Branch 0 taken 59582689 times.
✓ Branch 1 taken 2979 times.
59585668 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
21349 {
21350 2979 found = true;
21351 2979 }
21352 59585668 }
21353 29792834 }
21354
2/2
✓ Branch 0 taken 14894973 times.
✓ Branch 1 taken 1444 times.
14896417 if (found)
21355 {
21356 1444 ffcdata& ffc = tmpscr->ffcs[i];
21357 1444 newcombo const* cmb = &combobuf[ffc.getData()];
21358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1444 times.
1444 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
21359 {
21360 do_trigger_combo_ffc(i);
21361 }
21362 1444 }
21363 14896417 }
21364 470175 }
21365
21366 //
21367 // Now, let's check for Save combos...
21368 //
21369 478415 x1 = tx+4;
21370 478415 x2 = tx+11;
21371 478415 y1 = ty+4;
21372 478415 y2 = ty+11;
21373
21374 478415 types[0] = COMBOTYPE(x1,y1);
21375 478415 cids[0] = MAPCOMBO(x1,y1);
21376
21377
2/2
✓ Branch 0 taken 477574 times.
✓ Branch 1 taken 841 times.
478415 if(MAPFFCOMBO(x1,y1))
21378 {
21379 841 types[0] = FFCOMBOTYPE(x1,y1);
21380 841 cids[0] = MAPFFCOMBO(x1,y1);
21381 841 }
21382
21383 478415 types[1] = COMBOTYPE(x1,y2);
21384 478415 cids[1] = MAPCOMBO(x1,y2);
21385
21386
2/2
✓ Branch 0 taken 477730 times.
✓ Branch 1 taken 685 times.
478415 if(MAPFFCOMBO(x1,y2))
21387 {
21388 685 types[1] = FFCOMBOTYPE(x1,y2);
21389 685 cids[1] = MAPFFCOMBO(x1,y2);
21390 685 }
21391
21392 478415 types[2] = COMBOTYPE(x2,y1);
21393 478415 cids[2] = MAPCOMBO(x2,y1);
21394
21395
2/2
✓ Branch 0 taken 477659 times.
✓ Branch 1 taken 756 times.
478415 if(MAPFFCOMBO(x2,y1))
21396 {
21397 756 types[2] = FFCOMBOTYPE(x2,y1);
21398 756 cids[2] = MAPFFCOMBO(x2,y1);
21399 756 }
21400
21401 478415 types[3] = COMBOTYPE(x2,y2);
21402 478415 cids[3] = MAPCOMBO(x2,y2);
21403
21404
2/2
✓ Branch 0 taken 477909 times.
✓ Branch 1 taken 506 times.
478415 if(MAPFFCOMBO(x2,y2))
21405 {
21406 506 types[3] = FFCOMBOTYPE(x2,y2);
21407 506 cids[3] = MAPFFCOMBO(x2,y2);
21408 506 }
21409
21410
21411
2/2
✓ Branch 0 taken 478415 times.
✓ Branch 1 taken 1913660 times.
2392075 for(int32_t i=0; i<4; i++)
21412 {
21413
1/2
✓ Branch 0 taken 1913660 times.
✗ Branch 1 not taken.
1913660 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21414 {
21415 if(types[i] == cSAVE || types[i] == cSAVE2)
21416 {
21417 types[i] = cNONE;
21418 setsave = false;
21419 break;
21420 }
21421 }
21422
1/2
✓ Branch 0 taken 1913660 times.
✗ Branch 1 not taken.
1913660 if(types[i]==cSAVE) setsave=true;
21423
21424
1/2
✓ Branch 0 taken 1913660 times.
✗ Branch 1 not taken.
1913660 if(types[i]==cSAVE2) setsave=true;
21425 1913660 }
21426
21427
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 478415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
478415 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21428 {
21429 last_savepoint_id = cids[0];
21430 type = types[0];
21431 }
21432 //
21433 // Now, let's check for Drowning combos...
21434 //
21435
3/4
✓ Branch 0 taken 469174 times.
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 469174 times.
478415 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
21436 {
21437 9241 y1 = ty+9;
21438 9241 y2 = ty+15;
21439
1/2
✓ Branch 0 taken 9241 times.
✗ Branch 1 not taken.
9241 if (get_bit(quest_rules, qr_SMARTER_WATER))
21440 {
21441
3/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 9185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
9281 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
21442
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 16 times.
56 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
21443
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
21444 40 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
21445 9241 }
21446 else
21447 {
21448 types[0] = COMBOTYPE(x1,y1);
21449
21450 if(MAPFFCOMBO(x1,y1))
21451 types[0] = FFCOMBOTYPE(x1,y1);
21452
21453 types[1] = COMBOTYPE(x1,y2);
21454
21455 if(MAPFFCOMBO(x1,y2))
21456 types[1] = FFCOMBOTYPE(x1,y2);
21457
21458 types[2] = COMBOTYPE(x2,y1);
21459
21460 if(MAPFFCOMBO(x2,y1))
21461 types[2] = FFCOMBOTYPE(x2,y1);
21462
21463 types[3] = COMBOTYPE(x2,y2);
21464
21465 if(MAPFFCOMBO(x2,y2))
21466 types[3] = FFCOMBOTYPE(x2,y2);
21467
21468 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
21469 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
21470 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
21471
21472 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
21473 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
21474 water = typec;
21475 }
21476 9241 }
21477
21478
21479 // Pits have a bigger 'hitbox' than stairs...
21480 478415 x1 = tx+7;
21481 478415 x2 = tx+8;
21482 478415 y1 = ty+7+(bigHitbox?0:4);
21483 478415 y2 = ty+8+(bigHitbox?0:4);
21484
21485 478415 types[0] = COMBOTYPE(x1,y1);
21486 478415 cids[0] = MAPCOMBO(x1,y1);
21487
21488
2/2
✓ Branch 0 taken 477813 times.
✓ Branch 1 taken 602 times.
478415 if(MAPFFCOMBO(x1,y1))
21489 {
21490 602 types[0] = FFCOMBOTYPE(x1,y1);
21491 602 cids[0] = MAPFFCOMBO(x1,y1);
21492 602 }
21493
21494 478415 types[1] = COMBOTYPE(x1,y2);
21495 478415 cids[1] = MAPCOMBO(x1,y2);
21496
21497
2/2
✓ Branch 0 taken 477829 times.
✓ Branch 1 taken 586 times.
478415 if(MAPFFCOMBO(x1,y2))
21498 {
21499 586 types[1] = FFCOMBOTYPE(x1,y2);
21500 586 cids[1] = MAPFFCOMBO(x1,y2);
21501 586 }
21502 478415 types[2] = COMBOTYPE(x2,y1);
21503 478415 cids[2] = MAPCOMBO(x2,y1);
21504
21505
2/2
✓ Branch 0 taken 477857 times.
✓ Branch 1 taken 558 times.
478415 if(MAPFFCOMBO(x2,y1))
21506 {
21507 558 types[2] = FFCOMBOTYPE(x2,y1);
21508 558 cids[2] = MAPFFCOMBO(x2,y1);
21509 558 }
21510
21511 478415 types[3] = COMBOTYPE(x2,y2);
21512 478415 cids[3] = MAPCOMBO(x2,y2);
21513
21514
2/2
✓ Branch 0 taken 477873 times.
✓ Branch 1 taken 542 times.
478415 if(MAPFFCOMBO(x2,y2))
21515 {
21516 542 types[3] = FFCOMBOTYPE(x2,y2);
21517 542 cids[3] = MAPFFCOMBO(x2,y2);
21518 542 }
21519
21520
2/2
✓ Branch 0 taken 1913660 times.
✓ Branch 1 taken 478415 times.
2392075 for(int32_t i=0; i<4; i++)
21521 {
21522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913660 times.
1913660 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21523 {
21524 types[i] = cNONE;
21525 continue;
21526 }
21527
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1913582 times.
1913660 if(types[i]==cPIT)
21528 {
21529 78 index=0;
21530 78 warpsfx2 = combobuf[cids[i]].attribytes[0];
21531 78 }
21532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913582 times.
1913582 else if(types[i]==cPITB)
21533 {
21534 types[i]=cPIT;
21535 index=1;
21536 warpsfx2 = combobuf[cids[i]].attribytes[0];
21537 }
21538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1913582 times.
1913582 else if(types[i]==cPITC)
21539 {
21540 types[i]=cPIT;
21541 index=2;
21542 warpsfx2 = combobuf[cids[i]].attribytes[0];
21543 }
21544
1/2
✓ Branch 0 taken 1913582 times.
✗ Branch 1 not taken.
1913582 else if(types[i]==cPITD)
21545 {
21546 types[i]=cPIT;
21547 index=3;
21548 warpsfx2 = combobuf[cids[i]].attribytes[0];
21549 }
21550 1913660 }
21551
21552
6/8
✓ Branch 0 taken 478396 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 478396 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 478395 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 478395 times.
478415 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
21553
3/8
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
40 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21554 20 type=cPIT;
21555
21556 //
21557 // Time to act on our results for type, flag, flag2 and flag3...
21558 //
21559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 478415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
478415 if(type==cSAVE&&currscr<128)
21560 *ls=1;
21561
21562
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 478415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
478415 if(type==cSAVE2&&currscr<128)
21563 *ls=2;
21564
21565
6/8
✓ Branch 0 taken 473415 times.
✓ Branch 1 taken 5000 times.
✓ Branch 2 taken 469006 times.
✓ Branch 3 taken 4409 times.
✓ Branch 4 taken 469006 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 469006 times.
478415 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
21566 {
21567 9409 fairycircle(REFILL_LIFE);
21568
21569
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 1169 times.
9409 if(fairyclk!=0) return;
21570 1169 }
21571
21572
4/8
✓ Branch 0 taken 470175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 470175 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 470175 times.
470175 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
21573 {
21574 fairycircle(REFILL_MAGIC);
21575
21576 if(fairyclk!=0) return;
21577 }
21578
21579
4/8
✓ Branch 0 taken 470175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 470175 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 470175 times.
470175 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
21580 {
21581 fairycircle(REFILL_ALL);
21582
21583 if(fairyclk!=0) return;
21584 }
21585
21586 // Just in case Hero was moved off of the fairy flag
21587
1/2
✓ Branch 0 taken 470175 times.
✗ Branch 1 not taken.
470175 if(refilling==REFILL_FAIRYDONE)
21588 {
21589 fairycircle(REFILL_NONE);
21590
21591 if(fairyclk!=0) return;
21592 }
21593
21594
5/8
✓ Branch 0 taken 470174 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 470174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 470174 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 470174 times.
470175 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
21595 {
21596 1 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
21597 1 win_game();
21598 1 return;
21599 }
21600
21601
4/4
✓ Branch 0 taken 470054 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 470054 times.
✓ Branch 3 taken 120 times.
470174 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
21602 120 return;
21603
21604
2/4
✓ Branch 0 taken 470054 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 470054 times.
470054 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
21605 {
21606
21607 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
21608 {
21609 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
21610 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
21611 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
21612
21613 if(type==cTRIGFLAG && canPermSecret())
21614 {
21615 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
21616
21617 hidden_entrance(0,true,false);
21618 }
21619 else
21620 {
21621 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21622 hidden_entrance(0,true,only16_31);
21623 }
21624 }
21625 }
21626
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 470042 times.
470054 else if(!didstrig)
21627 {
21628 470042 stepsecret = -1;
21629 470042 }
21630
21631 //Better? Dock collision
21632
21633 // Drown if:
21634 // * Water (obviously walkable),
21635 // * Quest Rule allows it,
21636 // * Not on stepladder,
21637 // * Not jumping,
21638 // * Not hovering,
21639 // * Not rafting,
21640 // * Not swallowed,
21641 // * Not a dried lake.
21642
21643 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
21644
21645
10/22
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 470051 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
470054 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
21646 {
21647
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
21648 {
21649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(ladderx+laddery)) drownCombo = water;
21650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (combobuf[water].usrflags&cflag1) Drown(1);
21651 3 else Drown();
21652
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(byte drown_sfx = combobuf[water].attribytes[4])
21653 sfx(drown_sfx, pan(int32_t(x)));
21654 3 }
21655 else if (!isSwimming())
21656 {
21657 SetSwim();
21658 if (!IsSideSwim()) attackclk = charging = spins = 0;
21659 landswim=0;
21660 return;
21661 }
21662 3 }
21663
21664
21665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 470054 times.
470054 if(type==cSTEP)
21666 {
21667 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
21668 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
21669 {
21670 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
21671
21672 if
21673 (
21674 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
21675 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
21676 && /*HEAVY*/
21677 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21678 )
21679
21680 {
21681 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
21682 tmpscr->data[stepnext]++;
21683
21684 }
21685
21686 if
21687 (
21688 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
21689 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21690 && /*HEAVY*/
21691 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21692 )
21693 {
21694 int32_t stepc = tmpscr->data[stepnext];
21695 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21696 for(int32_t k=0; k<176; k++)
21697 {
21698 if(tmpscr->data[k]==stepc)
21699 {
21700 tmpscr->data[k]++;
21701 }
21702 }
21703 }
21704
21705 if
21706 (
21707 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
21708 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21709 && /*HEAVY*/
21710 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21711 )
21712 {
21713 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21714 for(int32_t k=0; k<176; k++)
21715 {
21716 if(
21717 (combobuf[tmpscr->data[k]].type==cSTEP)||
21718 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
21719 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
21720 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
21721 )
21722 {
21723 tmpscr->data[k]++;
21724 }
21725 }
21726 }
21727 }
21728 }
21729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 470054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
470054 else if(type==cSTEPSFX && action == walking)
21730 {
21731 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
21732 }
21733 470054 else stepnext = -1;
21734
21735 470054 detail_int[0]=tx;
21736 470054 detail_int[1]=ty;
21737
21738
21739
6/8
✓ Branch 0 taken 469957 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 103 times.
✓ Branch 3 taken 469951 times.
✓ Branch 4 taken 469593 times.
✓ Branch 5 taken 358 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
470054 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
21740
5/6
✓ Branch 0 taken 469573 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 469572 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 469572 times.
✗ Branch 5 not taken.
469593 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
21741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469572 times.
469572 !(type==cDIVEWARP && isDiving()))
21742 469572 {
21743 RaftingStuff:
21744
1/2
✓ Branch 0 taken 469572 times.
✗ Branch 1 not taken.
469572 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
21745 {
21746 bool doraft = true;
21747 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
21748 {
21749 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21750 {
21751 doraft = false;
21752 }
21753 }
21754 //if (mfRAFT)
21755 int32_t rafttypes[2];
21756 int32_t raftx1 = tx+6;
21757 int32_t raftx2 = tx+9;
21758 int32_t rafty = ty+11;
21759 int32_t raftflags[3];
21760 rafttypes[0]=rafttypes[1]=-1;
21761 raftflags[0]=raftflags[1]=raftflags[2]=0;
21762 rafttypes[0] = MAPFLAG(raftx1,rafty);
21763 rafttypes[1] = MAPFLAG(raftx2,rafty);
21764
21765 if(rafttypes[0]==rafttypes[1])
21766 raftflags[0] = rafttypes[0];
21767
21768
21769 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
21770 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
21771
21772 if(rafttypes[0]==rafttypes[1])
21773 raftflags[1] = rafttypes[0];
21774
21775 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
21776 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
21777
21778 if(rafttypes[0]==rafttypes[1])
21779 raftflags[2] = rafttypes[0];
21780
21781 for (int32_t m = 0; m < 3; ++m)
21782 {
21783 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
21784 {
21785 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
21786 {
21787 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
21788 {
21789 reset_swordcharge();
21790 action=rafting; FFCore.setHeroAction(rafting);
21791 raftclk=0;
21792 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21793 else sfx(tmpscr->secretsfx);
21794 }
21795 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21796 {
21797 for (int32_t i = 0; i < 4; ++i)
21798 {
21799 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
21800 {
21801 reset_swordcharge();
21802 action=rafting; FFCore.setHeroAction(rafting);
21803 raftclk=0;
21804 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21805 else sfx(tmpscr->secretsfx);
21806 dir = i;
21807 break;
21808 }
21809 }
21810 }
21811 }
21812 }
21813 }
21814 }
21815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469572 times.
469572 if (RaftPass) return;
21816
3/3
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 468394 times.
✓ Branch 2 taken 134 times.
469572 switch(flag)
21817 {
21818 case mfDIVE_ITEM:
21819
6/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
134 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21820 {
21821 4 additem(x, y, tmpscr->catchall,
21822 2 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21823 2 sfx(tmpscr->secretsfx);
21824 2 }
21825
21826 134 return;
21827
21828 case mfRAFT:
21829 case mfRAFT_BRANCH:
21830
21831 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
1044 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21833 {
21834 1044 bool doraft = true;
21835
5/6
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118 times.
✓ Branch 3 taken 926 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 73 times.
1044 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21836 {
21837
2/6
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
73 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21838 {
21839 doraft = false;
21840 }
21841 73 }
21842
11/16
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 800 times.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 47 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 47 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 47 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 30 times.
1044 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21843 {
21844
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
30 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
21845 {
21846 27 reset_swordcharge();
21847 27 action=rafting; FFCore.setHeroAction(rafting);
21848 27 raftclk=0;
21849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21850 27 else sfx(tmpscr->secretsfx);
21851 27 }
21852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21853 {
21854 for (int32_t i = 0; i < 4; ++i)
21855 {
21856 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21857 {
21858 reset_swordcharge();
21859 action=rafting; FFCore.setHeroAction(rafting);
21860 raftclk=0;
21861 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21862 else sfx(tmpscr->secretsfx);
21863 dir = i;
21864 break;
21865 }
21866 }
21867 }
21868 30 }
21869 1044 }
21870
21871 1044 return;
21872
21873 default:
21874 468394 break;
21875 //return;
21876 }
21877
21878
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 468394 times.
✗ Branch 2 not taken.
468394 switch(flag2)
21879 {
21880 case mfDIVE_ITEM:
21881 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21882 {
21883 additem(x, y, tmpscr->catchall,
21884 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21885 sfx(tmpscr->secretsfx);
21886 }
21887
21888 return;
21889
21890 case mfRAFT:
21891 case mfRAFT_BRANCH:
21892
21893 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21894 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21895 {
21896 bool doraft = true;
21897 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21898 {
21899 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21900 {
21901 doraft = false;
21902 }
21903 }
21904 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21905 {
21906 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
21907 {
21908 reset_swordcharge();
21909 action=rafting; FFCore.setHeroAction(rafting);
21910 raftclk=0;
21911 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21912 else sfx(tmpscr->secretsfx);
21913 }
21914 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21915 {
21916 for (int32_t i = 0; i < 4; ++i)
21917 {
21918 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21919 {
21920 reset_swordcharge();
21921 action=rafting; FFCore.setHeroAction(rafting);
21922 raftclk=0;
21923 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21924 else sfx(tmpscr->secretsfx);
21925 dir = i;
21926 break;
21927 }
21928 }
21929 }
21930 }
21931 }
21932
21933 return;
21934
21935 default:
21936 468394 break;
21937 //return;
21938 }
21939
21940
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 468394 times.
✗ Branch 2 not taken.
468394 switch(flag3)
21941 {
21942 case mfDIVE_ITEM:
21943 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21944 {
21945 additem(x, y, tmpscr->catchall,
21946 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21947 sfx(tmpscr->secretsfx);
21948 }
21949
21950 return;
21951
21952 case mfRAFT:
21953 case mfRAFT_BRANCH:
21954
21955 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21956 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21957 {
21958 bool doraft = true;
21959 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21960 {
21961 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21962 {
21963 doraft = false;
21964 }
21965 }
21966 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21967 {
21968 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
21969 {
21970 reset_swordcharge();
21971 action=rafting; FFCore.setHeroAction(rafting);
21972 raftclk=0;
21973 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21974 else sfx(tmpscr->secretsfx);
21975 }
21976 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21977 {
21978 for (int32_t i = 0; i < 4; ++i)
21979 {
21980 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21981 {
21982 reset_swordcharge();
21983 action=rafting; FFCore.setHeroAction(rafting);
21984 raftclk=0;
21985 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21986 else sfx(tmpscr->secretsfx);
21987 dir = i;
21988 break;
21989 }
21990 }
21991 }
21992 }
21993 }
21994
21995 return;
21996
21997 default:
21998 468394 return;
21999 }
22000 }
22001
22002
22003 482 int32_t t=(currscr<128)?0:1;
22004
22005
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 482 times.
✗ Branch 3 not taken.
482 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
22006
22007 //don't do this for canceled warps -DD
22008 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
22009 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
22010 {
22011 draw_screen(tmpscr);
22012 advanceframe(true);
22013 }*/
22014
22015 482 bool skippedaframe=false;
22016
22017
6/6
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 358 times.
✓ Branch 5 taken 21 times.
482 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
22018 {
22019 // Stop music only if:
22020 // * entering a Guy Cave
22021 // * warping to a DMap whose music is different.
22022
22023 461 int32_t tdm = tmpscr[t].tilewarpdmap[index];
22024
22025
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 92 times.
461 if(tmpscr[t].tilewarptype[index]<=wtPASS)
22026 {
22027
3/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 162 times.
369 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
22028 162 music_stop();
22029 369 }
22030 else
22031 {
22032
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 82 times.
92 if(zcmusic!=NULL)
22033 {
22034
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
22035
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
22036 10 music_stop();
22037 10 }
22038
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
82 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
22039 77 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
22040 77 music_stop();
22041 }
22042
22043 461 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
22044
5/6
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 207 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 162 times.
461 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
22045 254 ? false : COOLSCROLL);
22046
22047 461 FFCore.warpScriptCheck();
22048 461 draw_screen(tmpscr);
22049 461 advanceframe(true);
22050
22051 461 skippedaframe=true;
22052
22053
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 455 times.
461 if(type==cCAVE2) walkup2(opening);
22054
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 97 times.
455 else if(type==cCAVE) walkdown(opening);
22055 461 }
22056
22057
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 20 times.
482 if(type==cPIT)
22058 {
22059 20 didpit=true;
22060 20 pitx=x;
22061 20 pity=y;
22062 20 warp_sound = warpsfx2;
22063 20 }
22064
22065
5/6
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 213 times.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
521 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
22066
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
252 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
22067 {
22068
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(!skippedaframe)
22069 {
22070 FFCore.warpScriptCheck();
22071 draw_screen(tmpscr);
22072 advanceframe(true);
22073 }
22074
22075 // "take any road you want"
22076
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 10 times.
39 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
22077 39 int32_t code = WARPCODE(currdmap,homescr,dw);
22078
22079
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(code>-1)
22080 {
22081 39 bool changedlevel = false;
22082 39 bool changeddmap = false;
22083
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 9 times.
39 if(currdmap != code>>8)
22084 {
22085 9 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22086 9 changeddmap = true;
22087 9 }
22088
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(dlevel != DMaps[code>>8].level)
22089 {
22090 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22091 changedlevel = true;
22092 }
22093 39 currdmap = code>>8;
22094 39 dlevel = DMaps[currdmap].level;
22095
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 9 times.
39 if(changeddmap)
22096 {
22097 9 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22098 9 }
22099
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(changedlevel)
22100 {
22101 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22102 }
22103
22104 39 currmap = DMaps[currdmap].map;
22105 39 homescr = (code&0xFF) + DMaps[currdmap].xoff;
22106 39 init_dmap();
22107
22108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(canPermSecret())
22109 39 setmapflag(mSECRET);
22110 39 }
22111
22112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(specialcave==STAIRCAVE) exitcave();
22113
22114 39 return;
22115 }
22116
22117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(type==cRESET)
22118 {
22119 if(!skippedaframe)
22120 {
22121 FFCore.warpScriptCheck();
22122 draw_screen(tmpscr);
22123 advanceframe(true);
22124 }
22125
22126 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
22127
22128 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
22129
22130 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
22131
22132 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
22133
22134 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
22135
22136 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
22137
22138 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
22139
22140 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
22141
22142 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
22143
22144 if(isdungeon())
22145 {
22146 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
22147
22148 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
22149
22150 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
22151
22152 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
22153 }
22154
22155 didpit=true;
22156 pitx=x;
22157 pity=y;
22158 sdir=dir;
22159 dowarp(4,0, warpsfx2);
22160 }
22161 else
22162 {
22163
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
443 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
22164 {
22165 21 FFCore.warpScriptCheck();
22166 21 draw_screen(tmpscr);
22167 21 advanceframe(true);
22168 21 }
22169
22170 443 sdir = dir;
22171 443 dowarp(0,index, warpsfx2);
22172 }
22173 1980088 }
22174
22175 11 int32_t selectWlevel(int32_t d)
22176 {
22177
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(TriforceCount()==0)
22178 return 0;
22179
22180 11 word l = game->get_wlevel();
22181
22182 11 do
22183 {
22184
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
22185 break;
22186
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 5 times.
24 else if(d<0)
22187
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 l = (l==0) ? 7 : l-1;
22188 else
22189
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 17 times.
19 l = (l==7) ? 0 : l+1;
22190
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 11 times.
24 }
22191 24 while(!(game->lvlitems[l+1] & liTRIFORCE));
22192
22193 11 game->set_wlevel(l);
22194 11 return l;
22195 11 }
22196
22197 // Would someone tell the Dodongos to shut their yaps?!
22198 3121 void kill_enemy_sfx()
22199 {
22200
2/2
✓ Branch 0 taken 3121 times.
✓ Branch 1 taken 5171 times.
8292 for(int32_t i=0; i<guys.Count(); i++)
22201 {
22202
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 2803 times.
5171 if(((enemy*)guys.spr(i))->bgsfx)
22203 2803 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
22204 5171 }
22205
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3110 times.
3121 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
22206
2/2
✓ Branch 0 taken 3119 times.
✓ Branch 1 taken 2 times.
3121 if(tmpscr->room==rGANON)
22207 2 stop_sfx(WAV_ROAR);
22208 3121 }
22209
22210 94 bool HeroClass::HasHeavyBoots()
22211 {
22212
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 24064 times.
24158 for ( int32_t q = 0; q < MAXITEMS; ++q )
22213 {
22214
5/6
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 23796 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
24064 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
22215 24064 }
22216 94 return false;
22217 94 }
22218
22219 const char *roomtype_string[rMAX] =
22220 {
22221 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
22222 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
22223 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
22224 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
22225 };
22226
22227 555 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
22228 {
22229 555 byte reposition_sword_postwarp = 0;
22230
1/2
✓ Branch 0 taken 555 times.
✗ Branch 1 not taken.
555 if(index<0)
22231 {
22232 return false;
22233 }
22234 555 is_warping = true;
22235
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 555 times.
575 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
22236 {
22237 20 weapon *swd=NULL;
22238 20 swd = (weapon*)Lwpns.spr(q);
22239
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 if(swd->id == (attack==wSword ? wSword : wWand))
22240 {
22241 1 Lwpns.del(q);
22242 1 }
22243 20 }
22244
22245 555 attackclk = charging = spins = tapping = 0;
22246 555 attack = none;
22247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555 times.
555 if ( warp_sound > 0 ) warpsfx = warp_sound;
22248 555 warp_sound = 0;
22249 555 word wdmap=0;
22250 555 byte wscr=0,wtype=0,t=0;
22251 555 bool overlay=false;
22252 555 t=(currscr<128)?0:1;
22253 555 int32_t wrindex = 0;
22254 555 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
22255
22256 // Drawing commands probably shouldn't carry over...
22257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555 times.
555 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
22258 555 script_drawing_commands.Clear();
22259
22260
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
555 switch(type)
22261 {
22262 case 0: // tile warp
22263 443 wtype = tmpscr[t].tilewarptype[index];
22264 443 wdmap = tmpscr[t].tilewarpdmap[index];
22265 443 wscr = tmpscr[t].tilewarpscr[index];
22266 443 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
22267 443 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
22268 443 break;
22269
22270 case 1: // side warp
22271 101 wtype = tmpscr[t].sidewarptype[index];
22272 101 wdmap = tmpscr[t].sidewarpdmap[index];
22273 101 wscr = tmpscr[t].sidewarpscr[index];
22274 101 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
22275 101 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
22276 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
22277 //there is no doscript for screen scripts. They run like ffcs.
22278
22279 101 break;
22280
22281 case 2: // whistle warp
22282 {
22283 11 wtype = wtWHISTLE;
22284
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
22285 11 int32_t level=0;
22286
22287
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(blowcnt==0)
22288 level = selectWlevel(0);
22289 else
22290 {
22291
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 for(int32_t i=0; i<abs(blowcnt); i++)
22292 11 level = selectWlevel(blowcnt);
22293 }
22294
22295
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
22296 {
22297 level %= QMisc.warp[wind].size;
22298 game->set_wlevel(level);
22299 }
22300
22301 11 wdmap = QMisc.warp[wind].dmap[level];
22302 11 wscr = QMisc.warp[wind].scr[level];
22303 }
22304 11 break;
22305
22306 case 3:
22307 wtype = wtIWARP;
22308 wdmap = cheat_goto_dmap;
22309 wscr = cheat_goto_screen;
22310 break;
22311
22312 case 4:
22313 wtype = wtIWARP;
22314 wdmap = currdmap;
22315 wscr = homescr-DMaps[currdmap].xoff;
22316 break;
22317 }
22318
22319 555 bool intradmap = (wdmap == currdmap);
22320 555 int32_t olddmap = currdmap;
22321 555 rehydratelake(type!=wtSCROLL);
22322
22323
7/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 18 times.
555 switch(wtype)
22324 {
22325 case wtCAVE:
22326 {
22327 // cave/item room
22328 204 ALLOFF();
22329 204 homescr=currscr;
22330 204 currscr=0x80;
22331
22332
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 81 times.
204 if(DMaps[currdmap].flags&dmfCAVES) // cave
22333 {
22334 123 music_stop();
22335 123 kill_sfx();
22336
22337
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 80 times.
123 if(tmpscr->room==rWARP)
22338 {
22339 43 currscr=0x81;
22340 43 specialcave = STAIRCAVE;
22341 43 }
22342 80 else specialcave = GUYCAVE;
22343
22344 //lighting(2,dir);
22345 123 lighting(false, true);
22346 123 loadlvlpal(10);
22347
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 38 times.
208 bool b2 = COOLSCROLL&&
22348
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
85 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
22349
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
22350
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
22351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
22352 123 blackscr(30,b2?false:true);
22353 123 loadscr(0,wdmap,currscr,up,false);
22354 123 loadscr(1,wdmap,homescr,up,false);
22355 //preloaded freeform combos
22356 123 ffscript_engine(true);
22357 123 putscr(scrollbuf,0,0,tmpscr);
22358 123 putscrdoors(scrollbuf,0,0,tmpscr);
22359 123 dir=up;
22360 123 x=112;
22361 123 y=160;
22362
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(didpit)
22363 {
22364 didpit=false;
22365 x=pitx;
22366 y=pity;
22367 }
22368
22369 123 reset_hookshot();
22370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(reposition_sword_postwarp)
22371 {
22372 weapon *swd=NULL;
22373 for(int32_t i=0; i<Lwpns.Count(); i++)
22374 {
22375 swd = (weapon*)Lwpns.spr(i);
22376
22377 if(swd->id == (attack==wSword ? wSword : wWand))
22378 {
22379 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22380 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22381 positionSword(swd,item_id);
22382 break;
22383 }
22384 }
22385 }
22386 123 stepforward(diagonalMovement?5:6, false);
22387 123 }
22388 else // item room
22389 {
22390 81 specialcave = ITEMCELLAR;
22391 81 map_bkgsfx(false);
22392 81 kill_enemy_sfx();
22393 81 draw_screen(tmpscr,false);
22394
22395 //unless the room is already dark, fade to black
22396
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(!darkroom)
22397 {
22398 80 darkroom = true;
22399 80 fade(DMaps[currdmap].color,true,false);
22400 80 }
22401
22402 81 blackscr(30,true);
22403 81 loadscr(0,wdmap,currscr,down,false);
22404 81 loadscr(1,wdmap,homescr,-1,false);
22405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if ( dontdraw < 2 ) { dontdraw=1; }
22406 81 draw_screen(tmpscr);
22407 81 fade(11,true,true);
22408 81 darkroom = false;
22409 81 dir=down;
22410 81 x=48;
22411 81 y=0;
22412
22413 // is this didpit check necessary?
22414
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(didpit)
22415 {
22416 didpit=false;
22417 x=pitx;
22418 y=pity;
22419 }
22420
22421 81 reset_hookshot();
22422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(reposition_sword_postwarp)
22423 {
22424 weapon *swd=NULL;
22425 for(int32_t i=0; i<Lwpns.Count(); i++)
22426 {
22427 swd = (weapon*)Lwpns.spr(i);
22428
22429 if(swd->id == (attack==wSword ? wSword : wWand))
22430 {
22431 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22432 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22433 positionSword(swd,item_id);
22434 break;
22435 }
22436 }
22437 }
22438 81 lighting(false, true);
22439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if ( dontdraw < 2 ) { dontdraw=0; }
22440 81 stepforward(diagonalMovement?16:18, false);
22441 }
22442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
22443 204 break;
22444 }
22445
22446 case wtPASS: // passageway
22447 {
22448 126 map_bkgsfx(false);
22449 126 kill_enemy_sfx();
22450 126 ALLOFF();
22451 //play sound
22452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22453 126 homescr=currscr;
22454 126 currscr=0x81;
22455 126 specialcave = PASSAGEWAY;
22456 126 byte warpscr2 = wscr + DMaps[wdmap].xoff;
22457 126 draw_screen(tmpscr,false);
22458
22459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
22460 {
22461
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 119 times.
126 if(!darkroom)
22462 119 fade(DMaps[currdmap].color,true,false);
22463
22464 126 darkroom=true;
22465 126 }
22466 126 blackscr(30,true);
22467 126 loadscr(0,wdmap,currscr,down,false);
22468 126 loadscr(1,wdmap,homescr,-1,false);
22469 //preloaded freeform combos
22470 126 ffscript_engine(true);
22471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( dontdraw < 2 ) { dontdraw=1; }
22472 126 draw_screen(tmpscr);
22473 126 lighting(false, true);
22474 126 dir=down;
22475 126 x=48;
22476
22477
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 60 times.
126 if((homescr&15) > (warpscr2&15))
22478 {
22479 60 x=192;
22480 60 }
22481
22482
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 1 times.
126 if((homescr&15) == (warpscr2&15))
22483 {
22484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if((currscr>>4) > (warpscr2>>4))
22485 {
22486 1 x=192;
22487 1 }
22488 1 }
22489
22490 // is this didpit check necessary?
22491
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(didpit)
22492 {
22493 didpit=false;
22494 x=pitx;
22495 y=pity;
22496 }
22497
22498 126 y=0;
22499 126 set_respawn_point();
22500 126 trySideviewLadder();
22501 126 reset_hookshot();
22502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(reposition_sword_postwarp)
22503 {
22504 weapon *swd=NULL;
22505 for(int32_t i=0; i<Lwpns.Count(); i++)
22506 {
22507 swd = (weapon*)Lwpns.spr(i);
22508
22509 if(swd->id == (attack==wSword ? wSword : wWand))
22510 {
22511 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22512 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22513 positionSword(swd,item_id);
22514 break;
22515 }
22516 }
22517 }
22518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( dontdraw < 2 ) { dontdraw=0; }
22519 126 stepforward(diagonalMovement?16:18, false);
22520 126 newscr_clk=frame;
22521 126 activated_timed_warp=false;
22522 126 stepoutindex=index;
22523 126 stepoutscr = warpscr2;
22524 126 stepoutdmap = wdmap;
22525 126 stepoutwr=wrindex;
22526 }
22527 126 break;
22528
22529 case wtEXIT: // entrance/exit
22530 {
22531 149 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
22532 149 ALLOFF();
22533 149 music_stop();
22534 149 kill_sfx();
22535 149 blackscr(30,false);
22536 149 bool changedlevel = false;
22537 149 bool changeddmap = false;
22538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(currdmap != wdmap)
22539 {
22540 149 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22541 149 changeddmap = true;
22542 149 }
22543
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 148 times.
149 if(dlevel != DMaps[wdmap].level)
22544 {
22545 148 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22546 148 changedlevel = true;
22547 148 }
22548 149 dlevel = DMaps[wdmap].level;
22549 149 currdmap = wdmap;
22550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(changeddmap)
22551 {
22552 149 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22553 149 }
22554
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 148 times.
149 if(changedlevel)
22555 {
22556 148 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22557 148 }
22558
22559 149 currmap=DMaps[currdmap].map;
22560 149 init_dmap();
22561 149 update_subscreens(wdmap);
22562 149 loadfullpal();
22563 149 ringcolor(false);
22564 149 loadlvlpal(DMaps[currdmap].color);
22565 //lastentrance_dmap = currdmap;
22566 149 homescr = currscr = wscr + DMaps[currdmap].xoff;
22567 149 loadscr(0,currdmap,currscr,-1,overlay);
22568
22569
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
22570 {
22571 if(get_bit(quest_rules,qr_FADE))
22572 {
22573 interpolatedfade();
22574 }
22575 else
22576 {
22577 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
22578 }
22579
22580 darkroom=naturaldark=true;
22581 }
22582 else
22583 {
22584 149 darkroom=naturaldark=false;
22585 }
22586
22587 int32_t wrx,wry;
22588
22589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22590 {
22591 wrx=tmpscr->warpreturnx[0];
22592 wry=tmpscr->warpreturny[0];
22593 }
22594 else
22595 {
22596 149 wrx=tmpscr->warparrivalx;
22597 149 wry=tmpscr->warparrivaly;
22598 }
22599
22600
6/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 125 times.
149 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22601 {
22602
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 42 times.
125 if(dlevel)
22603 {
22604 83 lastentrance = currscr;
22605 83 }
22606 else
22607 {
22608 42 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22609 }
22610
22611 125 lastentrance_dmap = wdmap;
22612 125 }
22613
22614
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 66 times.
149 if(dlevel)
22615 {
22616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22617 {
22618 x=tmpscr->warpreturnx[wrindex];
22619 y=tmpscr->warpreturny[wrindex];
22620 }
22621 else
22622 {
22623 83 x=tmpscr->warparrivalx;
22624 83 y=tmpscr->warparrivaly;
22625 }
22626 83 }
22627 else
22628 {
22629 66 x=tmpscr->warpreturnx[wrindex];
22630 66 y=tmpscr->warpreturny[wrindex];
22631 }
22632
22633
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(didpit)
22634 {
22635 didpit=false;
22636 x=pitx;
22637 y=pity;
22638 }
22639
22640 149 dir=down;
22641
22642
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 139 times.
149 if(x==0) dir=right;
22643
22644
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 141 times.
149 if(x==240) dir=left;
22645
22646
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 145 times.
149 if(y==0) dir=down;
22647
22648
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 87 times.
149 if(y==160) dir=up;
22649
22650
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 66 times.
149 if(dlevel)
22651 {
22652 // reset enemy kill counts
22653
2/2
✓ Branch 0 taken 10624 times.
✓ Branch 1 taken 83 times.
10707 for(int32_t i=0; i<128; i++)
22654 {
22655 10624 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
22656 10624 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
22657 10624 }
22658 83 }
22659
22660 149 markBmap(dir^1);
22661 //preloaded freeform combos
22662 149 ffscript_engine(true);
22663
22664 149 reset_hookshot();
22665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(reposition_sword_postwarp)
22666 {
22667 weapon *swd=NULL;
22668 for(int32_t i=0; i<Lwpns.Count(); i++)
22669 {
22670 swd = (weapon*)Lwpns.spr(i);
22671
22672 if(swd->id == (attack==wSword ? wSword : wWand))
22673 {
22674 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22675 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22676 positionSword(swd,item_id);
22677 break;
22678 }
22679 }
22680 }
22681
22682
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 73 times.
149 if(isdungeon())
22683 {
22684 76 openscreen();
22685
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
22686 76 stepforward(diagonalMovement?11:12, false);
22687 else
22688 // Didn't walk as far pre-1.93, and some quests depend on that
22689 stepforward(8, false);
22690 76 }
22691 else
22692 {
22693
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 50 times.
73 if(!COOLSCROLL)
22694 23 openscreen();
22695
22696 73 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
22697 73 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22698 73 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
22699
22700
5/10
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 33 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
73 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
22701 {
22702 40 reset_pal_cycling();
22703 40 putscr(scrollbuf,0,0,tmpscr);
22704 40 putscrdoors(scrollbuf,0,0,tmpscr);
22705 40 walkup(COOLSCROLL);
22706 40 }
22707
5/10
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
33 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
22708 {
22709 2 reset_pal_cycling();
22710 2 putscr(scrollbuf,0,0,tmpscr);
22711 2 putscrdoors(scrollbuf,0,0,tmpscr);
22712 2 walkdown2(COOLSCROLL);
22713 2 }
22714
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 13 times.
31 else if(COOLSCROLL)
22715 {
22716 18 openscreen();
22717 18 }
22718 }
22719
22720 149 show_subscreen_life=true;
22721 149 show_subscreen_numbers=true;
22722 149 playLevelMusic();
22723 149 currcset=DMaps[currdmap].color;
22724 149 dointro();
22725 149 set_respawn_point();
22726 149 trySideviewLadder();
22727
22728
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 149 times.
1043 for(int32_t i=0; i<6; i++)
22729 894 visited[i]=-1;
22730
22731 149 break;
22732 }
22733
22734 case wtSCROLL: // scrolling warp
22735 {
22736 16 int32_t c = DMaps[currdmap].color;
22737 16 scrolling_map = currmap;
22738 16 currmap = DMaps[wdmap].map;
22739 16 update_subscreens(wdmap);
22740
22741 16 dlevel = DMaps[wdmap].level;
22742 //check if Hero has the map for the new location before updating the subscreen. ? -Z
22743 //This works only in one direction, if Hero had a map, to not having one.
22744 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
22745 16 update_subscreens(wdmap);
22746
22747 /*if ( has_item(itype_map, dlevel) )
22748 {
22749 //Blank the map during an intra-dmap scrolling warp.
22750 dlevel = -1; //a hack for the minimap. This works!! -Z
22751 }*/
22752
22753 // fix the scrolling direction, if it was a tile or instant warp
22754
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if(type==0 || type>=3)
22755 {
22756 sdir = dir;
22757 }
22758
22759 16 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
22760 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
22761
22762 16 reset_hookshot();
22763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(reposition_sword_postwarp)
22764 {
22765 weapon *swd=NULL;
22766 for(int32_t i=0; i<Lwpns.Count(); i++)
22767 {
22768 swd = (weapon*)Lwpns.spr(i);
22769
22770 if(swd->id == (attack==wSword ? wSword : wWand))
22771 {
22772 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22773 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22774 positionSword(swd,item_id);
22775 break;
22776 }
22777 }
22778 }
22779
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(!intradmap)
22780 {
22781 12 homescr = currscr = wscr + DMaps[wdmap].xoff;
22782 12 init_dmap();
22783
22784 int32_t wrx,wry;
22785
22786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22787 {
22788 wrx=tmpscr->warpreturnx[0];
22789 wry=tmpscr->warpreturny[0];
22790 }
22791 else
22792 {
22793 12 wrx=tmpscr->warparrivalx;
22794 12 wry=tmpscr->warparrivaly;
22795 }
22796
22797
4/8
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22798 {
22799 if(dlevel)
22800 {
22801 lastentrance = currscr;
22802 }
22803 else
22804 {
22805 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22806 }
22807
22808 lastentrance_dmap = wdmap;
22809 }
22810 12 }
22811
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(DMaps[currdmap].color != c)
22812 {
22813 lighting(false, true);
22814 }
22815
22816 16 playLevelMusic();
22817 16 currcset=DMaps[currdmap].color;
22818 16 dointro();
22819 }
22820 16 break;
22821
22822 case wtWHISTLE: // whistle warp
22823 {
22824 11 scrolling_map = currmap;
22825 11 currmap = DMaps[wdmap].map;
22826 11 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
22827 11 reset_hookshot();
22828 11 currdmap=wdmap;
22829 11 dlevel=DMaps[currdmap].level;
22830 11 lighting(false, true);
22831 11 init_dmap();
22832
22833 11 playLevelMusic();
22834 11 currcset=DMaps[currdmap].color;
22835 11 dointro();
22836 11 action=inwind; FFCore.setHeroAction(inwind);
22837 int32_t wry;
22838
22839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22840 wry=tmpscr->warpreturny[0];
22841 11 else wry=tmpscr->warparrivaly;
22842
22843 int32_t wrx;
22844
22845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22846 wrx=tmpscr->warpreturnx[0];
22847 11 else wrx=tmpscr->warparrivalx;
22848
22849
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
22 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
22850
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
22851 11 whirlwind=255;
22852 11 whistleitem=-1;
22853 }
22854 11 break;
22855
22856 case wtIWARP:
22857 case wtIWARPBLK:
22858 case wtIWARPOPEN:
22859 case wtIWARPZAP:
22860 case wtIWARPWAVE: // insta-warps
22861 {
22862 31 bool old_192 = false;
22863
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if (get_bit(quest_rules,qr_192b163_WARP))
22864 {
22865 if ( wtype == wtIWARPWAVE )
22866 {
22867 wtype = wtIWARPWAVE;
22868 old_192 = true;
22869 }
22870 if ( old_192 )
22871 {
22872 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
22873 didpit=false;
22874 update_subscreens();
22875 warp_sound = 0;
22876 is_warping = false;
22877 return false;
22878 }
22879 }
22880 //for determining whether to exit cave
22881 31 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
22882 31 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22883 31 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
22884
22885
5/8
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29 times.
60 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
22886
4/8
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
29 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
22887
22888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
22889 {
22890 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
22891 31 bool wasswimming = (action == swimming);
22892 31 int32_t olddiveclk = diveclk;
22893 31 ALLOFF();
22894
22895
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
31 if(wasswimming)
22896 {
22897 1 Hero.SetSwim();
22898 1 diveclk = olddiveclk;
22899 1 }
22900
22901 31 kill_sfx();
22902 31 }
22903 //play sound
22904
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22905
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 27 times.
31 if(wtype==wtIWARPZAP)
22906 {
22907 4 zapout();
22908 4 }
22909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 else if(wtype==wtIWARPWAVE)
22910 {
22911 //only draw Hero if he's not in a cave -DD
22912 wavyout(!cavewarp);
22913 }
22914
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6 times.
27 else if(wtype!=wtIWARP)
22915 {
22916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 bool b2 = COOLSCROLL&&cavewarp;
22917 6 blackscr(30,b2?false:true);
22918 6 }
22919
22920 31 int32_t c = DMaps[currdmap].color;
22921 31 bool changedlevel = false;
22922 31 bool changeddmap = false;
22923
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 26 times.
31 if(currdmap != wdmap)
22924 {
22925 26 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22926 26 changeddmap = true;
22927 26 }
22928
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6 times.
31 if(dlevel != DMaps[wdmap].level)
22929 {
22930 6 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22931 6 changedlevel = true;
22932 6 }
22933 31 dlevel = DMaps[wdmap].level;
22934 31 currdmap = wdmap;
22935
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 26 times.
31 if(changeddmap)
22936 {
22937 26 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22938 26 }
22939
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6 times.
31 if(changedlevel)
22940 {
22941 6 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22942 6 }
22943
22944 31 currmap = DMaps[currdmap].map;
22945 31 init_dmap();
22946 31 update_subscreens(wdmap);
22947
22948 31 ringcolor(false);
22949
22950
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 4 times.
31 if(DMaps[currdmap].color != c)
22951 4 loadlvlpal(DMaps[currdmap].color);
22952
22953 31 homescr = currscr = wscr + DMaps[currdmap].xoff;
22954
22955 31 lightingInstant(); // Also sets naturaldark
22956
22957 31 loadscr(0,currdmap,currscr,-1,overlay);
22958
22959 31 x = tmpscr->warpreturnx[wrindex];
22960 31 y = tmpscr->warpreturny[wrindex];
22961
22962
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 20 times.
31 if(didpit)
22963 {
22964 20 didpit=false;
22965 20 x=pitx;
22966 20 y=pity;
22967 20 }
22968
22969 31 type1 = combobuf[MAPCOMBO(x,y-16)].type;
22970 31 type2 = combobuf[MAPCOMBO(x,y)].type;
22971 31 type3 = combobuf[MAPCOMBO(x,y+16)].type;
22972
22973
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
31 if(x==0) dir=right;
22974
22975
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(x==240) dir=left;
22976
22977
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(y==0) dir=down;
22978
22979
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
31 if(y==160) dir=up;
22980
22981 31 markBmap(dir^1);
22982
22983 31 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
22984
22985
10/16
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 30 times.
32 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
22986 {
22987 1 hopclk=0xFF;
22988 1 SetSwim();
22989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!IsSideSwim()) attackclk = charging = spins = 0;
22990 1 }
22991 else
22992 {
22993 30 action = none; FFCore.setHeroAction(none);
22994 }
22995 //preloaded freeform combos
22996 31 ffscript_engine(true);
22997
22998 31 putscr(scrollbuf,0,0,tmpscr);
22999 31 putscrdoors(scrollbuf,0,0,tmpscr);
23000
23001
5/10
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
31 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23002 {
23003 2 reset_pal_cycling();
23004 2 putscr(scrollbuf,0,0,tmpscr);
23005 2 putscrdoors(scrollbuf,0,0,tmpscr);
23006 2 walkup(COOLSCROLL);
23007 2 }
23008
4/10
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
29 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23009 {
23010 reset_pal_cycling();
23011 putscr(scrollbuf,0,0,tmpscr);
23012 putscrdoors(scrollbuf,0,0,tmpscr);
23013 walkdown2(COOLSCROLL);
23014 }
23015
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 25 times.
29 else if(wtype==wtIWARPZAP)
23016 {
23017 4 zapin();
23018 4 }
23019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 else if(wtype==wtIWARPWAVE)
23020 {
23021 wavyin();
23022 }
23023
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 2 times.
25 else if(wtype==wtIWARPOPEN)
23024 {
23025 2 openscreen();
23026 2 }
23027
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(reposition_sword_postwarp)
23028 {
23029 weapon *swd=NULL;
23030 for(int32_t i=0; i<Lwpns.Count(); i++)
23031 {
23032 swd = (weapon*)Lwpns.spr(i);
23033
23034 if(swd->id == (attack==wSword ? wSword : wWand))
23035 {
23036 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23037 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23038 positionSword(swd,item_id);
23039 break;
23040 }
23041 }
23042 }
23043 31 show_subscreen_life=true;
23044 31 show_subscreen_numbers=true;
23045 31 playLevelMusic();
23046 31 currcset=DMaps[currdmap].color;
23047 31 dointro();
23048 31 set_respawn_point();
23049 31 trySideviewLadder();
23050 }
23051 31 break;
23052
23053
23054 case wtNOWARP:
23055 {
23056 18 bool old_192 = false;
23057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (get_bit(quest_rules,qr_192b163_WARP))
23058 {
23059 wtype = wtIWARPWAVE;
23060 old_192 = true;
23061 }
23062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( old_192 )
23063 {
23064 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
23065 //for determining whether to exit cave
23066 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23067 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23068 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23069
23070 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23071 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23072
23073 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23074 {
23075 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23076 bool wasswimming = (action == swimming);
23077 int32_t olddiveclk = diveclk;
23078 ALLOFF();
23079
23080 if(wasswimming)
23081 {
23082 Hero.SetSwim();
23083 diveclk = olddiveclk;
23084 }
23085
23086 kill_sfx();
23087 }
23088 //play sound
23089 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23090 if(wtype==wtIWARPZAP)
23091 {
23092 zapout();
23093 }
23094 else if(wtype==wtIWARPWAVE)
23095 {
23096 //only draw Hero if he's not in a cave -DD
23097 wavyout(!cavewarp);
23098 }
23099 else if(wtype!=wtIWARP)
23100 {
23101 bool b2 = COOLSCROLL&&cavewarp;
23102 blackscr(30,b2?false:true);
23103 }
23104
23105 int32_t c = DMaps[currdmap].color;
23106 bool changedlevel = false;
23107 bool changeddmap = false;
23108 if(currdmap != wdmap)
23109 {
23110 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23111 changeddmap = true;
23112 }
23113 if(dlevel != DMaps[wdmap].level)
23114 {
23115 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23116 changedlevel = true;
23117 }
23118 dlevel = DMaps[wdmap].level;
23119 currdmap = wdmap;
23120 if(changeddmap)
23121 {
23122 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23123 }
23124 if(changedlevel)
23125 {
23126 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23127 }
23128 currmap = DMaps[currdmap].map;
23129 init_dmap();
23130 update_subscreens(wdmap);
23131
23132 ringcolor(false);
23133
23134 if(DMaps[currdmap].color != c)
23135 loadlvlpal(DMaps[currdmap].color);
23136
23137 homescr = currscr = wscr + DMaps[currdmap].xoff;
23138
23139 lightingInstant(); // Also sets naturaldark
23140
23141 loadscr(0,currdmap,currscr,-1,overlay);
23142
23143 x = tmpscr->warpreturnx[wrindex];
23144 y = tmpscr->warpreturny[wrindex];
23145
23146 if(didpit)
23147 {
23148 didpit=false;
23149 x=pitx;
23150 y=pity;
23151 }
23152
23153 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23154 type2 = combobuf[MAPCOMBO(x,y)].type;
23155 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23156
23157 if(x==0) dir=right;
23158
23159 if(x==240) dir=left;
23160
23161 if(y==0) dir=down;
23162
23163 if(y==160) dir=up;
23164
23165 markBmap(dir^1);
23166
23167 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
23168 {
23169 hopclk=0xFF;
23170 SetSwim();
23171 if (!IsSideSwim()) attackclk = charging = spins = 0;
23172 }
23173 else
23174 {
23175 action = none;
23176 FFCore.setHeroAction(none);
23177 }
23178 //preloaded freeform combos
23179 ffscript_engine(true);
23180
23181 putscr(scrollbuf,0,0,tmpscr);
23182 putscrdoors(scrollbuf,0,0,tmpscr);
23183
23184 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23185 {
23186 reset_pal_cycling();
23187 putscr(scrollbuf,0,0,tmpscr);
23188 putscrdoors(scrollbuf,0,0,tmpscr);
23189 walkup(COOLSCROLL);
23190 }
23191 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23192 {
23193 reset_pal_cycling();
23194 putscr(scrollbuf,0,0,tmpscr);
23195 putscrdoors(scrollbuf,0,0,tmpscr);
23196 walkdown2(COOLSCROLL);
23197 }
23198 else if(wtype==wtIWARPZAP)
23199 {
23200 zapin();
23201 }
23202 else if(wtype==wtIWARPWAVE)
23203 {
23204 wavyin();
23205 }
23206 else if(wtype==wtIWARPOPEN)
23207 {
23208 openscreen();
23209 }
23210 if(reposition_sword_postwarp)
23211 {
23212 weapon *swd=NULL;
23213 for(int32_t i=0; i<Lwpns.Count(); i++)
23214 {
23215 swd = (weapon*)Lwpns.spr(i);
23216
23217 if(swd->id == (attack==wSword ? wSword : wWand))
23218 {
23219 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23220 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23221 positionSword(swd,item_id);
23222 break;
23223 }
23224 }
23225 }
23226 show_subscreen_life=true;
23227 show_subscreen_numbers=true;
23228 playLevelMusic();
23229 currcset=DMaps[currdmap].color;
23230 dointro();
23231 set_respawn_point();
23232 trySideviewLadder();
23233 break;
23234 }
23235 else
23236 {
23237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(reposition_sword_postwarp)
23238 {
23239 weapon *swd=NULL;
23240 for(int32_t i=0; i<Lwpns.Count(); i++)
23241 {
23242 swd = (weapon*)Lwpns.spr(i);
23243
23244 if(swd->id == (attack==wSword ? wSword : wWand))
23245 {
23246 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23247 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23248 positionSword(swd,item_id);
23249 break;
23250 }
23251 }
23252 }
23253 18 didpit=false;
23254 18 update_subscreens();
23255 18 warp_sound = 0;
23256 18 is_warping = false;
23257 18 return false;
23258 }
23259 }
23260 default:
23261 didpit=false;
23262 update_subscreens();
23263 warp_sound = 0;
23264 is_warping = false;
23265 if(reposition_sword_postwarp)
23266 {
23267 weapon *swd=NULL;
23268 for(int32_t i=0; i<Lwpns.Count(); i++)
23269 {
23270 swd = (weapon*)Lwpns.spr(i);
23271
23272 if(swd->id == (attack==wSword ? wSword : wWand))
23273 {
23274 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23275 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23276 positionSword(swd,item_id);
23277 break;
23278 }
23279 }
23280 }
23281 return false;
23282 }
23283
23284
23285
23286 // Stop Hero from drowning!
23287
3/6
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 537 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 537 times.
537 if(action==drowning || action==lavadrowning || action==sidedrowning)
23288 {
23289 drownclk=0;
23290 drownclk=0;
23291 action=none; FFCore.setHeroAction(none);
23292 }
23293
23294 537 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
23295 // But keep him swimming if he ought to be!
23296 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
23297
9/12
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 527 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 535 times.
✓ Branch 11 taken 2 times.
544 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
23298 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
23299
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
7 && (action!=inwind))
23300 {
23301 2 hopclk=0xFF;
23302 2 SetSwim();
23303 2 }
23304
23305 537 newscr_clk=frame;
23306 537 activated_timed_warp=false;
23307 537 eat_buttons();
23308
23309
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 516 times.
537 if(wtype!=wtIWARP)
23310 516 attackclk=0;
23311
23312 537 didstuff=0;
23313 537 usecounts.clear();
23314 537 map_bkgsfx(true);
23315 537 loadside=dir^1;
23316 537 whistleclk=-1;
23317
23318
2/4
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 537 times.
✗ Branch 3 not taken.
537 if((z>0 || fakez>0) && isSideViewHero())
23319 {
23320 y-=z;
23321 y-=fakez;
23322 fakez=0;
23323 z=0;
23324 }
23325
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 536 times.
537 else if(!isSideViewHero())
23326 {
23327 536 fall=0;
23328 536 fakefall=0;
23329 536 }
23330
23331 // If warping between top-down and sideview screens,
23332 // fix enemies that are carried over by Full Screen Warp
23333 537 const bool tmpscr_is_sideview = isSideViewHero();
23334
23335
4/4
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 1 times.
537 if(!wasSideview && tmpscr_is_sideview)
23336 {
23337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<guys.Count(); i++)
23338 {
23339 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
23340 {
23341 guys.spr(i)->y -= guys.spr(i)->z;
23342 guys.spr(i)->y -= guys.spr(i)->fakez;
23343 guys.spr(i)->z = 0;
23344 guys.spr(i)->fakez = 0;
23345 }
23346
23347 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23348 guys.spr(i)->yofs += 2;
23349 }
23350 1 }
23351
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 535 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
536 else if(wasSideview && !tmpscr_is_sideview)
23352 {
23353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<guys.Count(); i++)
23354 {
23355 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23356 guys.spr(i)->yofs -= 2;
23357 }
23358 1 }
23359
23360
6/6
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 265 times.
✓ Branch 4 taken 71 times.
✓ Branch 5 taken 1 times.
537 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
23361 {
23362
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 203 times.
271 if(dlevel)
23363 {
23364 int32_t wrx,wry;
23365
23366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23367 {
23368 wrx=tmpscr->warpreturnx[0];
23369 wry=tmpscr->warpreturny[0];
23370 }
23371 else
23372 {
23373 68 wrx=tmpscr->warparrivalx;
23374 68 wry=tmpscr->warparrivaly;
23375 }
23376
23377
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
68 if((wtype == wtEXIT)
23378
5/10
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
68 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
23379 {
23380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
23381 {
23382 21 game->set_continue_scrn(homescr);
23383 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
23384 21 }
23385 else if(currdmap != game->get_continue_dmap())
23386 {
23387 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23388 }
23389 21 }
23390 else
23391 {
23392
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(currdmap != game->get_continue_dmap())
23393 {
23394 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23395 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
23396 }
23397 }
23398 68 }
23399 else
23400 {
23401 203 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23402 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
23403 }
23404
23405 271 game->set_continue_dmap(currdmap);
23406 271 lastentrance_dmap = currdmap;
23407 271 lastentrance = game->get_continue_scrn();
23408 //Z_message("continue_map = %d\n",game->get_continue_dmap());
23409 271 }
23410
23411
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(tmpscr->flags4&fAUTOSAVE)
23412 {
23413 save_game(true,0);
23414 }
23415
23416
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(tmpscr->flags6&fCONTINUEHERE)
23417 {
23418 lastentrance_dmap = currdmap;
23419 lastentrance = homescr;
23420 }
23421
23422 537 update_subscreens();
23423 537 verifyBothWeapons();
23424
23425
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 204 times.
537 if(wtype==wtCAVE)
23426 {
23427
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 81 times.
204 if(DMaps[currdmap].flags&dmfGUYCAVES)
23428 246 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
23429 123 (char *)moduledata.roomtype_names[tmpscr[1].room]);
23430 else
23431 81 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
23432 204 }
23433 666 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
23434
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 207 times.
540 wtype==wtPASS ? "Passageway" :
23435
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 58 times.
265 wtype==wtEXIT ? "Entrance/Exit" :
23436
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 42 times.
58 wtype==wtSCROLL ? "Scrolling Warp" :
23437 42 wtype==wtWHISTLE ? "Whistle Warp" :
23438 "Insta-Warp");
23439
23440 537 eventlog_mapflags();
23441
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(reposition_sword_postwarp)
23442 {
23443 weapon *swd=NULL;
23444 for(int32_t i=0; i<Lwpns.Count(); i++)
23445 {
23446 swd = (weapon*)Lwpns.spr(i);
23447
23448 if(swd->id == (attack==wSword ? wSword : wWand))
23449 {
23450 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23451 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23452 positionSword(swd,item_id);
23453 break;
23454 }
23455 }
23456 }
23457 537 FFCore.init_combo_doscript();
23458
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
537 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
23459 {
23460 537 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
23461 537 FFCore.initZScriptDMapScripts();
23462 537 FFCore.initZScriptActiveSubscreenScript();
23463 537 }
23464 537 is_warping = false;
23465 537 return true;
23466 555 }
23467
23468 94 void HeroClass::exitcave()
23469 {
23470 94 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23471 94 currscr=homescr;
23472 94 loadscr(0,currdmap,currscr,255,false); // bogus direction
23473 94 x = tmpscr->warpreturnx[0];
23474 94 y = tmpscr->warpreturny[0];
23475
23476
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(didpit)
23477 {
23478 didpit=false;
23479 x=pitx;
23480 y=pity;
23481 }
23482
23483
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2 times.
94 if(x+y == 0)
23484 2 x = y = 80;
23485
23486 94 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23487 94 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23488 94 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23489
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 71 times.
171 bool b = COOLSCROLL &&
23490
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 49 times.
71 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
23491
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 48 times.
49 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
23492
4/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 45 times.
48 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
23493
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 2 times.
45 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
23494 100 ALLOFF();
23495 100 blackscr(30,b?false:true);
23496 100 ringcolor(false);
23497 100 loadlvlpal(DMaps[currdmap].color);
23498 100 lighting(false, true);
23499 100 music_stop();
23500 100 kill_sfx();
23501 100 putscr(scrollbuf,0,0,tmpscr);
23502 100 putscrdoors(scrollbuf,0,0,tmpscr);
23503
23504
9/10
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 63 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
100 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23505 {
23506 39 walkup(COOLSCROLL);
23507 39 }
23508
9/10
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
63 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23509 {
23510 5 walkdown2(COOLSCROLL);
23511 5 }
23512
23513 104 show_subscreen_life=true;
23514 104 show_subscreen_numbers=true;
23515 104 playLevelMusic();
23516 104 currcset=DMaps[currdmap].color;
23517 104 dointro();
23518 104 newscr_clk=frame;
23519 104 activated_timed_warp=false;
23520 104 dir=down;
23521 104 set_respawn_point();
23522 104 eat_buttons();
23523 104 didstuff=0;
23524 104 usecounts.clear();
23525 104 map_bkgsfx(true);
23526 104 loadside=dir^1;
23527 104 }
23528
23529
23530 2186 void HeroClass::stepforward(int32_t steps, bool adjust)
23531 {
23532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2186 times.
2186 if ( FFCore.nostepforward ) return;
23533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2186 times.
2186 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
23534 2186 zfix tx=x; //temp x
23535 2186 zfix ty=y; //temp y
23536 2186 zfix tstep(0); //temp single step distance
23537 2186 zfix s(0); //calculated step distance for all steps
23538 2186 z3step=2;
23539 2186 int32_t sh=shiftdir;
23540 2186 shiftdir=-1;
23541
23542
2/2
✓ Branch 0 taken 38070 times.
✓ Branch 1 taken 2186 times.
40256 for(int32_t i=steps; i>0; --i)
23543 {
23544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38070 times.
38070 if(diagonalMovement)
23545 {
23546 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23547 {
23548 tstep = 1.5;
23549 }
23550 else
23551 {
23552 tstep=z3step;
23553 z3step=(z3step%2)+1;
23554 }
23555 }
23556 else
23557 {
23558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38070 times.
38070 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
23559 {
23560 tstep = 1.5;
23561 }
23562 else
23563 {
23564
2/2
✓ Branch 0 taken 22020 times.
✓ Branch 1 taken 16050 times.
38070 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
23565
23566
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12371 times.
✓ Branch 2 taken 9649 times.
✓ Branch 3 taken 7076 times.
✓ Branch 4 taken 8974 times.
38070 switch(dir)
23567 {
23568 case up:
23569 12371 ty-=tstep;
23570 12371 break;
23571
23572 case down:
23573 9649 ty+=tstep;
23574 9649 break;
23575
23576 case left:
23577 7076 tx-=tstep;
23578 7076 break;
23579
23580 case right:
23581 8974 tx+=tstep;
23582 8974 break;
23583 }
23584 }
23585 }
23586
23587 38070 s+=tstep;
23588 38070 }
23589
23590 2186 z3step=2;
23591
23592 2186 x = x.getInt();
23593 2186 y = y.getInt();
23594
2/2
✓ Branch 0 taken 40217 times.
✓ Branch 1 taken 2186 times.
42403 while(s>=0)
23595 {
23596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40217 times.
40217 if(diagonalMovement)
23597 {
23598 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23599 {
23600 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23601 {
23602 walkable = false;
23603 shiftdir = -1;
23604 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23605 switch(tdir)
23606 {
23607 case left:
23608 --x;
23609 break;
23610 case right:
23611 ++x;
23612 break;
23613 case up:
23614 --y;
23615 break;
23616 case down:
23617 ++y;
23618 break;
23619 }
23620 }
23621 else
23622 {
23623 walkable=false;
23624 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23625 move(dir, 150);
23626 }
23627 }
23628 else
23629 {
23630 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23631 {
23632 s-=1.5;
23633 }
23634 else
23635 {
23636 s-=z3step;
23637 }
23638 walkable=true;
23639 move(dir, 150);
23640 }
23641
23642 shiftdir=-1;
23643 }
23644 else
23645 {
23646
3/6
✓ Branch 0 taken 23297 times.
✓ Branch 1 taken 16920 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
40217 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23647 {
23648 walkable=false;
23649 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23650 switch(tdir)
23651 {
23652 case left:
23653 --x;
23654 break;
23655 case right:
23656 ++x;
23657 break;
23658 case up:
23659 --y;
23660 break;
23661 case down:
23662 ++y;
23663 break;
23664 }
23665 }
23666 else
23667 {
23668
2/4
✓ Branch 0 taken 40217 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40217 times.
40217 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23669 {
23670 s-=1.5;
23671 }
23672
2/2
✓ Branch 0 taken 23297 times.
✓ Branch 1 taken 16920 times.
40217 else if(dir<left)
23673 {
23674 23297 s-=lsteps[y.getInt()&7];
23675 23297 }
23676 else
23677 {
23678 16920 s-=lsteps[x.getInt()&7];
23679 }
23680
23681 40217 move(dir, 150);
23682 }
23683 }
23684
23685
2/2
✓ Branch 0 taken 38031 times.
✓ Branch 1 taken 2186 times.
40217 if(s<0)
23686 {
23687 // Not quite sure how this is actually supposed to work.
23688 // There have to be two cases for each direction or Hero
23689 // either walks too far onto the screen or may get stuck
23690 // going through walk-through walls.
23691
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 378 times.
✓ Branch 4 taken 493 times.
2186 switch(dir)
23692 {
23693 case up:
23694
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 744 times.
805 if(y<8) // Leaving the screen
23695 61 y+=s;
23696 else // Entering the screen
23697 744 y-=s;
23698
23699 805 break;
23700
23701 case down:
23702
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 463 times.
510 if(y>152)
23703 47 y-=s;
23704 else
23705 463 y+=s;
23706
23707 510 break;
23708
23709 case left:
23710
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 338 times.
378 if(x<8)
23711 40 x+=s;
23712 else
23713 338 x-=s;
23714
23715 378 break;
23716
23717 case right:
23718
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 443 times.
493 if(x>=232)
23719 50 x-=s;
23720 else
23721 443 x+=s;
23722
23723 493 break;
23724 }
23725 2186 }
23726
23727
23728 40217 draw_screen(tmpscr);
23729
1/2
✓ Branch 0 taken 40217 times.
✗ Branch 1 not taken.
40217 if (canSideviewLadder()) setOnSideviewLadder(true);
23730 40217 advanceframe(true);
23731
23732
1/2
✓ Branch 0 taken 40217 times.
✗ Branch 1 not taken.
40217 if(Quit)
23733 return;
23734 }
23735
4/4
✓ Branch 0 taken 1693 times.
✓ Branch 1 taken 493 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 1183 times.
2186 if(dir==right||dir==down)
23736 {
23737 1003 x=int32_t(x);
23738 1003 y=int32_t(y);
23739 1003 }
23740 else
23741 {
23742 1183 x = x.getInt();
23743 1183 y = y.getInt();
23744 }
23745 2186 set_respawn_point();
23746 2186 draw_screen(tmpscr);
23747 2186 eat_buttons();
23748 2186 shiftdir=sh;
23749 2186 }
23750
23751 97 void HeroClass::walkdown(bool opening) //entering cave
23752 {
23753
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 68 times.
97 if(opening)
23754 {
23755 68 close_black_opening(x+8, y+8+playing_field_offset, false);
23756 68 }
23757
23758 97 hclk=0;
23759 97 stop_item_sfx(itype_brang);
23760 97 sfx(WAV_STAIRS,pan(x.getInt()));
23761 97 clk=0;
23762 // int32_t cmby=(y.getInt()&0xF0)+16;
23763 // Fix Hero's position to the grid
23764 97 y=y.getInt()&0xF0;
23765 97 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23766 97 attack=wNone;
23767 97 attackid=-1;
23768 97 reset_swordcharge();
23769 97 climb_cover_x=x.getInt()&0xF0;
23770 97 climb_cover_y=(y.getInt()&0xF0)+16;
23771
23772 97 guys.clear();
23773 97 chainlinks.clear();
23774 97 Lwpns.clear();
23775 97 Ewpns.clear();
23776 97 items.clear();
23777
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 6208 times.
6305 for(int32_t i=0; i<64; i++)
23778 {
23779 6208 herostep();
23780
23781
2/4
✓ Branch 0 taken 6208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6208 times.
6208 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23782 hero_count=(hero_count+1)%16;
23783
23784
2/2
✓ Branch 0 taken 4656 times.
✓ Branch 1 taken 1552 times.
6208 if((i&3)==3)
23785 1552 ++y;
23786
23787 6208 draw_screen(tmpscr);
23788 6208 advanceframe(true);
23789
23790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6208 times.
6208 if(Quit)
23791 break;
23792 6208 }
23793
23794 97 action=none; FFCore.setHeroAction(none);
23795 97 }
23796
23797 5 void HeroClass::walkdown2(bool opening) //exiting cave 2
23798 {
23799 5 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23800
23801
2/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
23802 y-=16;
23803
23804 5 dir=down;
23805 // Fix Hero's position to the grid
23806 5 y=y.getInt()&0xF0;
23807 5 z=fakez=fall=fakefall=0;
23808
23809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(opening)
23810 {
23811 5 open_black_opening(x+8, y+8+playing_field_offset+16, false);
23812 5 }
23813
23814 5 hclk=0;
23815 5 stop_item_sfx(itype_brang);
23816 5 sfx(WAV_STAIRS,pan(x.getInt()));
23817 5 clk=0;
23818 // int32_t cmby=y.getInt()&0xF0;
23819 5 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23820 5 attack=wNone;
23821 5 attackid=-1;
23822 5 reset_swordcharge();
23823 5 climb_cover_x=x.getInt()&0xF0;
23824 5 climb_cover_y=y.getInt()&0xF0;
23825
23826 5 guys.clear();
23827 5 chainlinks.clear();
23828 5 Lwpns.clear();
23829 5 Ewpns.clear();
23830 5 items.clear();
23831
23832
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 320 times.
325 for(int32_t i=0; i<64; i++)
23833 {
23834 320 herostep();
23835
23836
2/4
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 320 times.
320 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23837 hero_count=(hero_count+1)%16;
23838
23839
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 80 times.
320 if((i&3)==3)
23840 80 ++y;
23841
23842 320 draw_screen(tmpscr);
23843 320 advanceframe(true);
23844
23845
1/2
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
320 if(Quit)
23846 break;
23847 320 }
23848
23849 5 action=none; FFCore.setHeroAction(none);
23850 5 }
23851
23852 81 void HeroClass::walkup(bool opening) //exiting cave
23853 {
23854 81 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23855
23856
4/6
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
81 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
23857 y+=16;
23858
23859 // Fix Hero's position to the grid
23860 81 y=y.getInt()&0xF0;
23861 81 z=fakez=fall=fakefall=0;
23862
23863
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 59 times.
81 if(opening)
23864 {
23865 59 open_black_opening(x+8, y+8+playing_field_offset-16, false);
23866 59 }
23867
23868 81 hclk=0;
23869 81 stop_item_sfx(itype_brang);
23870 81 sfx(WAV_STAIRS,pan(x.getInt()));
23871 81 dir=down;
23872 81 clk=0;
23873 // int32_t cmby=y.getInt()&0xF0;
23874 81 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23875 81 attack=wNone;
23876 81 attackid=-1;
23877 81 reset_swordcharge();
23878 81 climb_cover_x=x.getInt()&0xF0;
23879 81 climb_cover_y=y.getInt()&0xF0;
23880
23881 81 guys.clear();
23882 81 chainlinks.clear();
23883 81 Lwpns.clear();
23884 81 Ewpns.clear();
23885 81 items.clear();
23886
23887
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 5184 times.
5265 for(int32_t i=0; i<64; i++)
23888 {
23889 5184 herostep();
23890
23891
2/4
✓ Branch 0 taken 5184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5184 times.
5184 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23892 hero_count=(hero_count+1)%16;
23893
23894
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 1296 times.
5184 if((i&3)==0)
23895 1296 --y;
23896
23897 5184 draw_screen(tmpscr);
23898 5184 advanceframe(true);
23899
23900
1/2
✓ Branch 0 taken 5184 times.
✗ Branch 1 not taken.
5184 if(Quit)
23901 break;
23902 5184 }
23903 81 map_bkgsfx(true);
23904 81 loadside=dir^1;
23905 81 action=none; FFCore.setHeroAction(none);
23906 81 }
23907
23908 6 void HeroClass::walkup2(bool opening) //entering cave2
23909 {
23910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(opening)
23911 {
23912 6 close_black_opening(x+8, y+8+playing_field_offset, false);
23913 6 }
23914
23915 6 hclk=0;
23916 6 stop_item_sfx(itype_brang);
23917 6 sfx(WAV_STAIRS,pan(x.getInt()));
23918 6 dir=up;
23919 6 clk=0;
23920 // int32_t cmby=y.getInt()&0xF0;
23921 6 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23922 6 attack=wNone;
23923 6 attackid=-1;
23924 6 reset_swordcharge();
23925 6 climb_cover_x=x.getInt()&0xF0;
23926 6 climb_cover_y=(y.getInt()&0xF0)-16;
23927
23928 6 guys.clear();
23929 6 chainlinks.clear();
23930 6 Lwpns.clear();
23931 6 Ewpns.clear();
23932 6 items.clear();
23933
23934
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 384 times.
390 for(int32_t i=0; i<64; i++)
23935 {
23936 384 herostep();
23937
23938
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23939 hero_count=(hero_count+1)%16;
23940
23941
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 96 times.
384 if((i&3)==0)
23942 96 --y;
23943
23944 384 draw_screen(tmpscr);
23945 384 advanceframe(true);
23946
23947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(Quit)
23948 break;
23949 384 }
23950 6 map_bkgsfx(true);
23951 6 loadside=dir^1;
23952 6 action=none; FFCore.setHeroAction(none);
23953 6 }
23954
23955 196 void HeroClass::stepout() // Step out of item cellars and passageways
23956 {
23957 196 int32_t sc = specialcave; // This gets erased by ALLOFF()
23958 196 ALLOFF();
23959 196 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23960 196 map_bkgsfx(false);
23961 196 kill_enemy_sfx();
23962 196 draw_screen(tmpscr,false);
23963 196 fade(sc>=GUYCAVE?10:11,true,false);
23964 196 blackscr(30,true);
23965 196 ringcolor(false);
23966
23967
4/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 89 times.
196 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
23968 {
23969 89 currdmap=stepoutdmap;
23970 89 currmap=DMaps[currdmap].map;
23971 89 dlevel=DMaps[currdmap].level;
23972
23973 //we might have just left a passage, so be sure to update the CSet record -DD
23974 89 currcset=DMaps[currdmap].color;
23975
23976 89 init_dmap();
23977 89 homescr=stepoutscr;
23978 89 }
23979
23980 196 currscr=homescr;
23981 196 loadscr(0,currdmap,currscr,255,false); // bogus direction
23982 196 draw_screen(tmpscr,false);
23983
23984
3/4
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 3 times.
196 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
23985 {
23986 193 darkroom = naturaldark = false;
23987 193 fade(DMaps[currdmap].color,true,true);
23988 193 }
23989 else
23990 {
23991 3 darkroom = naturaldark = true;
23992
23993
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(get_bit(quest_rules,qr_FADE))
23994 {
23995 1 interpolatedfade();
23996 1 }
23997 else
23998 {
23999 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24000 }
24001 3 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
24002 3 si+=3*48;
24003
24004
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for(int32_t i=0; i<16; i++)
24005 {
24006 48 RAMpal[CSET(9)+i] = _RGB(si);
24007 48 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
24008 48 si+=3;
24009 48 }
24010 }
24011
24012 196 x = tmpscr->warpreturnx[stepoutwr];
24013 196 y = tmpscr->warpreturny[stepoutwr];
24014
24015
1/2
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
196 if(didpit)
24016 {
24017 didpit=false;
24018 x=pitx;
24019 y=pity;
24020 }
24021
24022
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 192 times.
196 if(x+y == 0)
24023 4 x = y = 80;
24024
24025 196 dir=down;
24026
24027 196 set_respawn_point();
24028
24029 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
24030 196 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
24031
24032
4/6
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 193 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
196 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24033 {
24034 walkup(false);
24035 }
24036
4/6
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 193 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
196 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24037 {
24038 walkdown2(false);
24039 }
24040
24041 196 newscr_clk=frame;
24042 196 activated_timed_warp=false;
24043 196 didstuff=0;
24044 196 usecounts.clear();
24045 196 eat_buttons();
24046 196 markBmap(-1);
24047 196 map_bkgsfx(true);
24048
24049
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 27 times.
196 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
24050 {
24051 27 music_stop();
24052 27 playLevelMusic();
24053 27 }
24054
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
24055 {
24056 playLevelMusic();
24057 }
24058
24059 196 loadside=dir^1;
24060 196 }
24061
24062 3086 bool HeroClass::nextcombo_wf(int32_t d2)
24063 {
24064
5/8
✓ Branch 0 taken 3086 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3058 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 3058 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
3086 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
24065 3086 return false;
24066
24067 // assumes Hero is about to scroll screens
24068
24069 int32_t ns = nextscr(d2);
24070
24071 if(ns==0xFFFF)
24072 return false;
24073
24074 // want actual screen index, not game->maps[] index
24075 ns = (ns&127) + (ns>>7)*MAPSCRS;
24076
24077 int32_t cx = x;
24078 int32_t cy = y;
24079
24080 switch(d2)
24081 {
24082 case up:
24083 cy=160;
24084 break;
24085
24086 case down:
24087 cy=0;
24088 break;
24089
24090 case left:
24091 cx=240;
24092 break;
24093
24094 case right:
24095 cx=0;
24096 break;
24097 }
24098
24099 // check lower half of combo
24100 cy += 8;
24101
24102 // from MAPCOMBO()
24103 int32_t cmb = (cy&0xF0)+(cx>>4);
24104
24105 if(cmb>175)
24106 return true;
24107
24108 newcombo c = combobuf[TheMaps[ns].data[cmb]];
24109 bool dried = iswater_type(c.type) && DRIEDLAKE;
24110 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24111 int32_t b=1;
24112
24113 if(cx&8) b<<=2;
24114
24115 if(cy&8) b<<=1;
24116
24117 if((c.walk&b) && !dried && !swim)
24118 return true;
24119
24120 // next block (i.e. cnt==2)
24121 if(!(cx&8))
24122 {
24123 b<<=2;
24124 }
24125 else
24126 {
24127 c = combobuf[TheMaps[ns].data[++cmb]];
24128 dried = iswater_type(c.type) && DRIEDLAKE;
24129 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24130 b=1;
24131
24132 if(cy&8)
24133 {
24134 b<<=1;
24135 }
24136 }
24137
24138 return (c.walk&b) ? !dried && !swim : false;
24139 3086 }
24140
24141 bool HeroClass::nextcombo_solid(int32_t d2)
24142 {
24143 if(toogam || currscr>=128)
24144 return false;
24145
24146 // assumes Hero is about to scroll screens
24147
24148 int32_t ns = nextscr(d2);
24149
24150 if(ns==0xFFFF)
24151 return false;
24152
24153 // want actual screen index, not game->maps[] index
24154 ns = (ns&127) + (ns>>7)*MAPSCRS;
24155 int32_t screen = (ns%MAPSCRS);
24156 int32_t map = (ns - screen) / MAPSCRS;
24157
24158 int32_t cx = x;
24159 int32_t cy = y;
24160
24161 switch(d2)
24162 {
24163 case up:
24164 cy=160;
24165 break;
24166
24167 case down:
24168 cy=0;
24169 break;
24170
24171 case left:
24172 cx=240;
24173 break;
24174
24175 case right:
24176 cx=0;
24177 break;
24178 }
24179
24180 if(d2==up) cy += 8;
24181
24182 if(d2==left||d2==right) cy+=bigHitbox?0:8;
24183
24184 int32_t initcx = cx;
24185 int32_t initcy = cy;
24186 // from MAPCOMBO()
24187
24188 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
24189 {
24190 cx = initcx;
24191 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
24192 {
24193 int32_t cmb = (cy&0xF0)+(cx>>4);
24194
24195 if(cmb>175)
24196 {
24197 return true;
24198 }
24199
24200 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
24201
24202 int32_t b=1;
24203
24204 if(cx&8) b<<=2;
24205
24206 if(cy&8) b<<=1;
24207
24208 //bool bridgedetected = false;
24209
24210 int32_t walk = c.walk;
24211 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
24212 {
24213 for (int32_t m = 0; m <= 1; m++)
24214 {
24215 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
24216 if (cmb.type == cBRIDGE)
24217 {
24218 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
24219 {
24220 int efflag = (cmb.walk & 0xF0)>>4;
24221 int newsolid = (cmb.walk & 0xF);
24222 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
24223 }
24224 else walk &= cmb.walk;
24225 }
24226 else walk |= cmb.walk;
24227 }
24228 }
24229 /*
24230 if (bridgedetected)
24231 {
24232 continue;
24233 }*/
24234
24235 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
24236 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
24237
24238 if((walk&b) && !swim)
24239 {
24240 return true;
24241 }
24242 }
24243
24244 /*
24245 #if 0
24246
24247 //
24248 // next block (i.e. cnt==2)
24249 if(!(cx&8))
24250 {
24251 b<<=2;
24252 }
24253 else
24254 {
24255 c = combobuf[TheMaps[ns].data[++cmb]];
24256 dried = iswater_type(c.type) && DRIEDLAKE;
24257 //swim = iswater_type(c.type) && (current_item(itype_flippers));
24258 b=1;
24259
24260 if(cy&8)
24261 {
24262 b<<=1;
24263 }
24264 }
24265
24266 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24267
24268 if((c.walk&b) && !dried && !swim)
24269 {
24270 return true;
24271 }
24272
24273 cx+=8;
24274
24275 if(cx&7)
24276 {
24277 if(!(cx&8))
24278 {
24279 b<<=2;
24280 }
24281 else
24282 {
24283 c = combobuf[TheMaps[ns].data[++cmb]];
24284 dried = iswater_type(c.type) && DRIEDLAKE;
24285 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24286 b=1;
24287
24288 if(cy&8)
24289 {
24290 b<<=1;
24291 }
24292 }
24293
24294 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24295
24296 if((c.walk&b) && !dried && !swim)
24297 return true;
24298 }
24299
24300 #endif
24301 */
24302 }
24303
24304 return false;
24305 }
24306
24307 1981854 void HeroClass::checkscroll()
24308 {
24309 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
24310
2/4
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981854 times.
✗ Branch 3 not taken.
1981854 if(action == casting||action==sideswimcasting)
24311 return;
24312
24313
1/2
✓ Branch 0 taken 1981854 times.
✗ Branch 1 not taken.
1981854 if(toogam)
24314 {
24315 if(x<0 && (currscr&15)==0) x=0;
24316
24317 if(y<0 && currscr<16) y=0;
24318
24319 if(x>240 && (currscr&15)==15) x=240;
24320
24321 if(y>160 && currscr>=112) y=160;
24322 }
24323
24324
2/2
✓ Branch 0 taken 1980779 times.
✓ Branch 1 taken 1075 times.
1981854 if(y<0)
24325 {
24326 1075 bool doit=true;
24327 1075 y=0;
24328
24329
3/6
✓ Branch 0 taken 1075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1075 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1075 times.
1075 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24330 doit = false;
24331
24332
1/2
✓ Branch 0 taken 1075 times.
✗ Branch 1 not taken.
1075 if(nextcombo_wf(up))
24333 doit=false;
24334
24335
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1075 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1075 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
24336 {
24337 if(nextcombo_solid(up))
24338 doit=false;
24339 }
24340
24341
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1075 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1075 if(doit || action==inwind)
24342 {
24343
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 879 times.
1075 if(currscr>=128)
24344 {
24345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(specialcave >= GUYCAVE)
24346 exitcave();
24347 196 else stepout();
24348 196 }
24349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 879 times.
879 else if(action==inwind)
24350 {
24351 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24352 {
24353 action=none; FFCore.setHeroAction(none);
24354 restart_level();
24355 }
24356 else
24357 {
24358 dowarp(2,up);
24359 }
24360 }
24361
3/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 857 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
879 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24362 {
24363 22 sdir=up;
24364 22 dowarp(1,(tmpscr->sidewarpindex)&3);
24365 22 }
24366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857 times.
857 else if(!edge_of_dmap(up))
24367 {
24368 857 scrolling_map = currmap;
24369 857 scrollscr(up);
24370
24371
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 if(tmpscr->flags4&fAUTOSAVE)
24372 {
24373 save_game(true,0);
24374 }
24375
24376
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 if(tmpscr->flags6&fCONTINUEHERE)
24377 {
24378 lastentrance_dmap = currdmap;
24379 lastentrance = homescr;
24380 }
24381 857 }
24382 1075 }
24383 1075 }
24384
24385
2/2
✓ Branch 0 taken 1981331 times.
✓ Branch 1 taken 523 times.
1981854 if(y>160)
24386 {
24387 523 bool doit=true;
24388 523 y=160;
24389
24390
3/6
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 523 times.
523 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24391 doit = false;
24392
24393
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if(nextcombo_wf(down))
24394 doit=false;
24395
24396
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
523 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
24397 {
24398 if(nextcombo_solid(down))
24399 doit=false;
24400 }
24401
24402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if(doit || action==inwind)
24403 {
24404
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 458 times.
523 if(currscr>=128)
24405 {
24406
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if(specialcave >= GUYCAVE)
24407 65 exitcave();
24408 else stepout();
24409 65 }
24410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 458 times.
458 else if(action==inwind)
24411 {
24412 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24413 {
24414 action=none; FFCore.setHeroAction(none);
24415 restart_level();
24416 }
24417 else
24418 {
24419 dowarp(2,down);
24420 }
24421 }
24422
3/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 437 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
458 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24423 {
24424 21 sdir=down;
24425 21 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24426 21 }
24427
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 432 times.
437 else if(!edge_of_dmap(down))
24428 {
24429 432 scrolling_map = currmap;
24430 432 scrollscr(down);
24431
24432
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if(tmpscr->flags4&fAUTOSAVE)
24433 {
24434 save_game(true,0);
24435 }
24436
24437
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if(tmpscr->flags6&fCONTINUEHERE)
24438 {
24439 lastentrance_dmap = currdmap;
24440 lastentrance = homescr;
24441 }
24442 432 }
24443 523 }
24444 523 }
24445
24446
2/2
✓ Branch 0 taken 1981193 times.
✓ Branch 1 taken 661 times.
1981854 if(x<0)
24447 {
24448 661 bool doit=true;
24449 661 x=0;
24450
24451
3/6
✓ Branch 0 taken 661 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 661 times.
661 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24452 doit = false;
24453
24454
1/2
✓ Branch 0 taken 661 times.
✗ Branch 1 not taken.
661 if(nextcombo_wf(left))
24455 doit=false;
24456
24457
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 661 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
661 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
24458 {
24459 if(nextcombo_solid(left))
24460 doit=false;
24461 }
24462
24463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 661 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
661 if(doit || action==inwind)
24464 {
24465
1/2
✓ Branch 0 taken 661 times.
✗ Branch 1 not taken.
661 if(currscr>=128)
24466 {
24467 if(specialcave >= GUYCAVE)
24468 exitcave();
24469 else stepout();
24470 }
24471
24472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 661 times.
661 if(action==inwind)
24473 {
24474 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24475 {
24476 action=none; FFCore.setHeroAction(none);
24477 restart_level();
24478 }
24479 else
24480 {
24481 dowarp(2,left);
24482 }
24483 }
24484
3/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 646 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
661 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24485 {
24486 15 sdir=left;
24487 15 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24488 15 }
24489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 646 times.
646 else if(!edge_of_dmap(left))
24490 {
24491 646 scrolling_map = currmap;
24492 646 scrollscr(left);
24493
24494
1/2
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
646 if(tmpscr->flags4&fAUTOSAVE)
24495 {
24496 save_game(true,0);
24497 }
24498
24499
1/2
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
646 if(tmpscr->flags6&fCONTINUEHERE)
24500 {
24501 lastentrance_dmap = currdmap;
24502 lastentrance = homescr;
24503 }
24504 646 }
24505 661 }
24506 661 }
24507
24508
2/2
✓ Branch 0 taken 1981073 times.
✓ Branch 1 taken 781 times.
1981854 if(x>240)
24509 {
24510 781 bool doit=true;
24511 781 x=240;
24512
24513
3/6
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 781 times.
781 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24514 doit = false;
24515
24516
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(nextcombo_wf(right))
24517 doit=false;
24518
24519
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
781 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
24520 {
24521 if(nextcombo_solid(right))
24522 doit=false;
24523 }
24524
24525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
781 if(doit || action==inwind)
24526 {
24527
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(currscr>=128)
24528 {
24529 if(specialcave >= GUYCAVE)
24530 exitcave();
24531 else stepout();
24532 }
24533
24534
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 770 times.
781 if(action==inwind)
24535 {
24536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24537 {
24538 action=none; FFCore.setHeroAction(none);
24539 restart_level();
24540 }
24541 else
24542 {
24543 11 dowarp(2,right);
24544 }
24545 11 }
24546
3/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
770 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24547 {
24548 14 sdir=right;
24549 14 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
24550 14 }
24551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 else if(!edge_of_dmap(right))
24552 {
24553 756 scrolling_map = currmap;
24554 756 scrollscr(right);
24555
24556
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(tmpscr->flags4&fAUTOSAVE)
24557 {
24558 save_game(true,0);
24559 }
24560
24561
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(tmpscr->flags6&fCONTINUEHERE)
24562 {
24563 lastentrance_dmap = currdmap;
24564 lastentrance = homescr;
24565 }
24566 756 }
24567 781 }
24568 781 }
24569 1981854 }
24570
24571 // assumes current direction is in lastdir[3]
24572 // compares directions with scr->path and scr->exitdir
24573 8059 bool HeroClass::checkmaze(mapscr *scr, bool sound)
24574 {
24575
2/2
✓ Branch 0 taken 7985 times.
✓ Branch 1 taken 74 times.
8059 if(!(scr->flags&fMAZE))
24576 7985 return true;
24577
24578
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 62 times.
74 if(lastdir[3]==scr->exitdir)
24579 12 return true;
24580
24581
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 12 times.
112 for(int32_t i=0; i<4; i++)
24582
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 50 times.
100 if(lastdir[i]!=scr->path[i])
24583 50 return false;
24584
24585
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(sound)
24586 6 sfx(scr->secretsfx);
24587
24588 12 return true;
24589 8059 }
24590
24591 5368 bool HeroClass::edge_of_dmap(int32_t side)
24592 {
24593
2/2
✓ Branch 0 taken 5337 times.
✓ Branch 1 taken 31 times.
5368 if(checkmaze(tmpscr,false)==false)
24594 31 return false;
24595
24596 // needs fixin'
24597 // should check dmap style
24598
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1695 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 1273 times.
✓ Branch 4 taken 1510 times.
5337 switch(side)
24599 {
24600 case up:
24601 1695 return currscr<16;
24602
24603 case down:
24604 859 return currscr>=112;
24605
24606 case left:
24607
1/2
✓ Branch 0 taken 1273 times.
✗ Branch 1 not taken.
1273 if((currscr&15)==0)
24608 return true;
24609
24610
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 583 times.
1273 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24611 // if(dlevel)
24612 690 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
24613
24614 583 break;
24615
24616 case right:
24617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1510 times.
1510 if((currscr&15)==15)
24618 return true;
24619
24620
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 624 times.
1510 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24621 // if(dlevel)
24622 886 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
24623
24624 624 break;
24625 }
24626
24627 1207 return false;
24628 5368 }
24629
24630 30 bool HeroClass::lookaheadraftflag(int32_t d2)
24631 {
24632 // Helper for scrollscr that gets next combo on next screen.
24633 // Can use destscr for scrolling warps,
24634 // but assumes currmap is correct.
24635
24636 30 int32_t cx = x;
24637 30 int32_t cy = y + 8;
24638
24639 30 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24640 30 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24641 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24642 //Applying this here, too. -Z
24643
24644
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 8 times.
30 switch(d2)
24645 {
24646 case up:
24647 9 cy=160;
24648 9 break;
24649
24650 case down:
24651 10 cy=0;
24652 10 break;
24653
24654 case left:
24655 3 cx=240;
24656 3 break;
24657
24658 case right:
24659 8 cx=0;
24660 8 break;
24661 }
24662
24663 30 int32_t combo = (cy&0xF0)+(cx>>4);
24664
24665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(combo>175)
24666 return 0;
24667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
24668
24669 30 }
24670 2718 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
24671 {
24672 // Can use destscr for scrolling warps,
24673 // but assumes currmap is correct.
24674
24675 2718 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
24676 2718 int32_t cy = vbound(y + 8,0,160);
24677 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24678 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24679 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24680
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 439 times.
✓ Branch 3 taken 648 times.
✓ Branch 4 taken 770 times.
2718 switch(d2)
24681 {
24682 case up:
24683 861 cy=160;
24684 861 break;
24685
24686 case down:
24687 439 cy=0;
24688 439 break;
24689
24690 case left:
24691 648 cx=240;
24692 648 break;
24693
24694 case right:
24695 770 cx=0;
24696 770 break;
24697 }
24698
24699 2718 int32_t combo = (cy&0xF0)+(cx>>4);
24700
24701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(combo>175)
24702 return 0;
24703
24704 2718 return tmpscr[0].data[combo]; // entire combo code
24705 2718 }
24706
24707 2718 int32_t HeroClass::lookaheadflag(int32_t d2)
24708 {
24709 // Helper for scrollscr that gets next combo on next screen.
24710 // Can use destscr for scrolling warps,
24711 // but assumes currmap is correct.
24712
24713 2718 int32_t cx = vbound(x,0,240);
24714 2718 int32_t cy = vbound(y + 8,0,160);
24715
24716 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24717 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24718 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24719 //Applying this here, too. -Z
24720
24721
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 439 times.
✓ Branch 3 taken 648 times.
✓ Branch 4 taken 770 times.
2718 switch(d2)
24722 {
24723 case up:
24724 861 cy=160;
24725 861 break;
24726
24727 case down:
24728 439 cy=0;
24729 439 break;
24730
24731 case left:
24732 648 cx=240;
24733 648 break;
24734
24735 case right:
24736 770 cx=0;
24737 770 break;
24738 }
24739
24740 2718 int32_t combo = (cy&0xF0)+(cx>>4);
24741
24742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(combo>175)
24743 return 0;
24744
24745
2/2
✓ Branch 0 taken 2672 times.
✓ Branch 1 taken 46 times.
2718 if(!tmpscr[0].sflag[combo])
24746 {
24747 2672 return combobuf[tmpscr[0].data[combo]].flag; // flag
24748 }
24749
24750 46 return tmpscr[0].sflag[combo]; // flag
24751 2718 }
24752
24753 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
24754 446089 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
24755 {
24756 // For rafting (and possibly other esoteric things)
24757 // Hero's action should remain unchanged while scrolling,
24758 // but for the sake of scripts, here's an eye-watering kludge.
24759 446089 actiontype lastaction = action;
24760 446089 action=scrolling; FFCore.setHeroAction(scrolling);
24761
2/2
✓ Branch 0 taken 223038 times.
✓ Branch 1 taken 223051 times.
446089 if(waitdraw)
24762 {
24763 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
24764 223038 }
24765 else
24766 {
24767 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
24768 }
24769 446089 zfix storex = x, storey = y;
24770
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 122219 times.
✓ Branch 2 taken 61547 times.
✓ Branch 3 taken 119209 times.
✓ Branch 4 taken 143114 times.
446089 switch(scrolldir)
24771 {
24772 case up:
24773
2/2
✓ Branch 0 taken 104031 times.
✓ Branch 1 taken 18188 times.
122219 if(y < 160) y = 176;
24774
4/4
✓ Branch 0 taken 15747 times.
✓ Branch 1 taken 2441 times.
✓ Branch 2 taken 5026 times.
✓ Branch 3 taken 10721 times.
18188 else if(cx > 0 && !end_frames) y = sy + 156;
24775 7467 else y = 160;
24776
24777 122219 break;
24778
24779 case down:
24780
2/2
✓ Branch 0 taken 52249 times.
✓ Branch 1 taken 9298 times.
61547 if(y > 0) y = -16;
24781
4/4
✓ Branch 0 taken 8020 times.
✓ Branch 1 taken 1278 times.
✓ Branch 2 taken 2793 times.
✓ Branch 3 taken 5227 times.
9298 else if(cx > 0 && !end_frames) y = sy - 172;
24782 4071 else y = 0;
24783
24784 61547 break;
24785
24786 case left:
24787
2/2
✓ Branch 0 taken 109978 times.
✓ Branch 1 taken 9231 times.
119209 if(x < 240) x = 256;
24788
2/2
✓ Branch 0 taken 7930 times.
✓ Branch 1 taken 1301 times.
9231 else if(cx > 0) x = sx + 236;
24789 1301 else x = 240;
24790
24791 119209 break;
24792
24793 case right:
24794
2/2
✓ Branch 0 taken 132062 times.
✓ Branch 1 taken 11052 times.
143114 if(x > 0) x = -16;
24795
2/2
✓ Branch 0 taken 9506 times.
✓ Branch 1 taken 1546 times.
11052 else if(cx > 0) x = sx - 252;
24796 1546 else x = 0;
24797
24798 143114 break;
24799 }
24800
2/2
✓ Branch 0 taken 223038 times.
✓ Branch 1 taken 223051 times.
446089 if(waitdraw)
24801 {
24802
3/4
✓ Branch 0 taken 223038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189904 times.
✓ Branch 3 taken 33134 times.
223038 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
24803 {
24804 33134 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24805 33134 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
24806 33134 }
24807 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
24808
2/6
✓ Branch 0 taken 223038 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 223038 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
223038 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24809 {
24810 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24811 player_waitdraw = false;
24812 }
24813 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
24814
2/6
✓ Branch 0 taken 223038 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 223038 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
223038 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24815 {
24816 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24817 dmap_waitdraw = false;
24818 }
24819 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
24820
2/6
✓ Branch 0 taken 223038 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 223038 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
223038 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24821 {
24822 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24823 passive_subscreen_waitdraw = false;
24824 }
24825 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
24826
2/10
✓ Branch 0 taken 223038 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 223038 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
223038 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24827 {
24828 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24829 tmpscr->screen_waitdraw = 0;
24830 }
24831 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
24832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223038 times.
223038 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
24833 {
24834 223038 FFCore.itemScriptEngineOnWaitdraw();
24835 223038 }
24836 223038 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
24837 223038 }
24838 else
24839 {
24840
2/8
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 223051 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
223051 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24841 {
24842 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24843 }
24844 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
24845
3/4
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189065 times.
✓ Branch 3 taken 33986 times.
223051 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
24846 {
24847 33986 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24848 33986 }
24849 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
24850
4/6
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222199 times.
✓ Branch 3 taken 852 times.
✓ Branch 4 taken 222199 times.
✗ Branch 5 not taken.
223051 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
24851 {
24852 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24853 }
24854 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
24855
4/6
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 223051 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222199 times.
✓ Branch 5 taken 852 times.
223051 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24856 {
24857 852 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24858 852 }
24859 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
24860
4/6
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 223051 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222199 times.
✓ Branch 5 taken 852 times.
223051 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24861 {
24862 852 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24863 852 }
24864 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
24865 223051 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
24866
3/4
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 852 times.
✓ Branch 3 taken 222199 times.
223051 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
24867 222199 FFCore.itemScriptEngine();
24868 223051 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
24869
3/4
✓ Branch 0 taken 223051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222199 times.
✓ Branch 3 taken 852 times.
223051 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
24870 852 FFCore.itemScriptEngine();
24871 }
24872
24873 446089 x = storex, y = storey;
24874
24875 446089 action=lastaction; FFCore.setHeroAction(lastaction);
24876 446089 }
24877
24878 //Has solving the maze enabled a side warp?
24879 //Only used just before scrolling screens
24880 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
24881 // return true to abort the topmost scrollscr() call. -L
24882 2718 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
24883 {
24884
2/2
✓ Branch 0 taken 8154 times.
✓ Branch 1 taken 2718 times.
10872 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
24885
24886
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 2687 times.
2718 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
24887
24888
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2718 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
24889 {
24890 switch(scrolldir)
24891 {
24892 case up:
24893 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
24894 {
24895 lastdir[3] = 0xFF;
24896 sdir=up;
24897 dowarp(1,(tmpscr->sidewarpindex)&3);
24898 return true;
24899 }
24900
24901 break;
24902
24903 case down:
24904 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
24905 {
24906 lastdir[3] = 0xFF;
24907 sdir=down;
24908 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24909 return true;
24910 }
24911
24912 break;
24913
24914 case left:
24915 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
24916 {
24917 lastdir[3] = 0xFF;
24918 sdir=left;
24919 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24920 return true;
24921 }
24922
24923 break;
24924
24925 case right:
24926 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
24927 {
24928 lastdir[3] = 0xFF;
24929 sdir=right;
24930 dowarp(1,(tmpscr->sidewarpindex)&3);
24931 return true;
24932 }
24933
24934 break;
24935 }
24936 }
24937
24938 2718 return false;
24939 2718 }
24940
24941 2718 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
24942 {
24943 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
24944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
24945 return 16;
24946
24947
2/2
✓ Branch 0 taken 2333 times.
✓ Branch 1 taken 385 times.
2718 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
24948 {
24949
2/2
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 1363 times.
2333 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
24950 }
24951 else
24952 {
24953
4/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 202 times.
385 if(scrolldir == up || scrolldir == down)
24954 {
24955 183 return 8;
24956 }
24957 else
24958 {
24959
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 102 times.
202 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
24960 }
24961 }
24962 2718 }
24963
24964 2718 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
24965 {
24966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(get_bit(quest_rules, qr_NOSCROLL))
24967 return 0;
24968
24969
3/4
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2333 times.
✓ Branch 3 taken 385 times.
2718 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
24970 2718 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
24971 {
24972 2333 return 1;
24973 }
24974 else
24975 {
24976
4/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 202 times.
385 if(scrolldir == up || scrolldir == down)
24977 {
24978
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 81 times.
183 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
24979 }
24980 else
24981 {
24982 202 return 1;
24983 }
24984 }
24985 2718 }
24986
24987 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
24988 {
24989 int32_t itemid = current_item_id(itype_lantern);
24990 if(itemid < 0) return; //no lantern light circle
24991 int32_t hx1 = x.getInt() - x1 + 8;
24992 int32_t hy1 = y.getInt() - y1 + 8;
24993 int32_t hx2 = x.getInt() - x2 + 8;
24994 int32_t hy2 = y.getInt() - y2 + 8;
24995
24996 itemdata& lamp = itemsbuf[itemid];
24997 switch(lamp.misc1) //Shape
24998 {
24999 case 0: //Circle
25000 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
25001 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
25002 break;
25003 case 1: //Lamp Cone
25004 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
25005 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
25006 break;
25007 }
25008 }
25009
25010 2718 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
25011 {
25012
2/4
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
2718 if(action==freeze||action==sideswimfreeze)
25013 {
25014 return;
25015 }
25016
25017 2718 bool overlay = false;
25018
25019
2/4
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
2718 if(scrolldir >= 0 && scrolldir <= 3)
25020 {
25021 2718 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
25022 2718 }
25023
25024
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2691 times.
2718 if(destdmap == -1)
25025 {
25026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2691 times.
2691 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
25027
1/2
✓ Branch 0 taken 2691 times.
✗ Branch 1 not taken.
2691 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
25028 return;
25029 2691 }
25030 else
25031 {
25032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
25033
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
25034 return;
25035 }
25036
25037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
25038 return;
25039
25040 2718 kill_enemy_sfx();
25041 2718 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25042 2718 screenscrolling = true;
25043 2718 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
25044
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 439 times.
✓ Branch 3 taken 648 times.
✓ Branch 4 taken 770 times.
2718 switch(scrolldir)
25045 {
25046 case up:
25047 861 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25048 861 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
25049 861 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25050 861 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25051 861 break;
25052 case down:
25053 439 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25054 439 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
25055 439 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25056 439 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25057 439 break;
25058 case left:
25059 648 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
25060 648 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25061 648 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25062 648 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25063 648 break;
25064 case right:
25065 770 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
25066 770 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25067 770 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25068 770 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25069 770 break;
25070 }
25071 2718 FFCore.init_combo_doscript();
25072 2718 tmpscr[1] = tmpscr[0];
25073
25074 2718 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
25075
25076
2/2
✓ Branch 0 taken 16308 times.
✓ Branch 1 taken 2718 times.
19026 for(int32_t i = 0; i < 6; i++)
25077 {
25078 16308 tmpscr3[i] = tmpscr2[i];
25079 16308 }
25080
25081 2718 conveyclk = 2;
25082
25083 2718 mapscr *newscr = &tmpscr[0];
25084 2718 mapscr *oldscr = &tmpscr[1];
25085
25086 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
25087 2718 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
25088 2718 int32_t cx = 0;
25089 2718 int32_t step = get_scroll_step(scrolldir);
25090 2718 int32_t delay = get_scroll_delay(scrolldir);
25091 2718 bool end_frames = false;
25092
25093 2718 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
25094
1/2
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
2718 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
25095 scx = 32; //for sideview very fast screolling.
25096
25097
25098 2718 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
25099 2718 actiontype lastaction = action;
25100 2718 ALLOFF(false, false);
25101 // for now, restore Hero's previous action
25102
2/2
✓ Branch 0 taken 2705 times.
✓ Branch 1 taken 13 times.
2718 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
25103 2718 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
25104 2718 action=lastaction; FFCore.setHeroAction(lastaction);
25105
25106 2718 lstep = (lstep + 6) % 12;
25107 2718 cx = scx;
25108 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25109
3/4
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2149 times.
✓ Branch 3 taken 569 times.
2718 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25110 {
25111 569 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25112 569 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
25113 569 }
25114 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25115
2/6
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2718 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25116 {
25117 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25118 player_waitdraw = false;
25119 }
25120 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25121
2/6
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2718 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25122 {
25123 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25124 dmap_waitdraw = false;
25125 }
25126 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25127
2/6
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2718 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25128 {
25129 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25130 passive_subscreen_waitdraw = false;
25131 }
25132 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25133
2/8
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2718 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25134 {
25135 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25136 tmpscr->screen_waitdraw = 0;
25137 }
25138 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25139
25140 2718 word c = tmpscr->numFFC();
25141
2/2
✓ Branch 0 taken 86736 times.
✓ Branch 1 taken 2718 times.
89454 for ( word q = 0; q < c; ++q )
25142 {
25143 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
25144
1/2
✓ Branch 0 taken 86736 times.
✗ Branch 1 not taken.
86736 if ( tmpscr->ffcswaitdraw&(1<<q) )
25145 {
25146 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
25147 if(tmpscr->ffcs[q].script != 0)
25148 {
25149 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
25150 tmpscr->ffcswaitdraw &= ~(1<<q);
25151 }
25152 }
25153 86736 }
25154 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
25155 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
25156 //Waitdraw for item scripts.
25157 2718 FFCore.itemScriptEngineOnWaitdraw();
25158 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25159 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
25160
25161 //Sprite scripts on Waitdraw
25162 2718 FFCore.eweaponScriptEngineOnWaitdraw();
25163 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
25164 2718 FFCore.itemSpriteScriptEngineOnWaitdraw();
25165 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
25166
25167 //This is no longer a do-while, as the first iteration is now slightly different. -Em
25168 2718 draw_screen(tmpscr,true,true);
25169
25170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(cx == scx)
25171 2718 rehydratelake(false);
25172
25173 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25174 2718 advanceframe(true);
25175
25176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2718 times.
2718 if(Quit)
25177 {
25178 screenscrolling = false;
25179 return;
25180 }
25181
25182 2718 ++cx;
25183
2/2
✓ Branch 0 taken 62148 times.
✓ Branch 1 taken 2718 times.
64866 while(cx < 32)
25184 {
25185
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 62135 times.
62148 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
25186 {
25187 13 script_drawing_commands.Clear();
25188 13 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25189 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
25190 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25191 13 }
25192 62135 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25193 62148 draw_screen(tmpscr,true,true);
25194
25195
1/2
✓ Branch 0 taken 62148 times.
✗ Branch 1 not taken.
62148 if(cx == scx)
25196 rehydratelake(false);
25197
25198 62148 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25199 62148 advanceframe(true);
25200
25201
1/2
✓ Branch 0 taken 62148 times.
✗ Branch 1 not taken.
62148 if(Quit)
25202 {
25203 screenscrolling = false;
25204 return;
25205 }
25206
25207 62148 ++cx;
25208 }
25209 2718 script_drawing_commands.Clear();
25210 2718 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25211
25212
25213 //clear Hero's last hits
25214 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
25215
25216
3/4
✓ Branch 0 taken 1102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 1565 times.
2718 switch(DMaps[currdmap].type&dmfTYPE)
25217 {
25218 case dmDNGN:
25219
1/2
✓ Branch 0 taken 1565 times.
✗ Branch 1 not taken.
1565 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
25220 {
25221 markBmap(scrolldir);
25222 }
25223 1565 break;
25224 case dmOVERW: case dmBSOVERW:
25225
2/2
✓ Branch 0 taken 1089 times.
✓ Branch 1 taken 13 times.
1102 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
25226 1089 break;
25227 [[fallthrough]];
25228 case dmCAVE:
25229 64 markBmap(scrolldir);
25230 64 break;
25231 }
25232
25233
1/2
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
2718 if(fixed_door)
25234 {
25235 unsetmapflag(mSECRET);
25236 fixed_door = false;
25237 }
25238 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
25239 2718 scrolling_scr = currscr;
25240
25241
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 439 times.
✓ Branch 3 taken 648 times.
✓ Branch 4 taken 770 times.
2718 switch(scrolldir)
25242 {
25243 case up:
25244 {
25245
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 857 times.
861 if(destscr != -1)
25246 4 currscr = destscr;
25247
3/4
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 848 times.
857 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25248 848 currscr -= 16;
25249
25250 861 loadscr(0,destdmap,currscr,scrolldir,overlay);
25251 861 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
25252 861 putscr(scrollbuf,0,0,newscr);
25253 861 putscrdoors(scrollbuf,0,0,newscr);
25254 861 sy=176;
25255
25256
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 143 times.
861 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25257 143 sy+=3;
25258
25259 861 cx=176/step;
25260 861 FFCore.init_combo_doscript();
25261 }
25262 861 break;
25263
25264 case down:
25265 {
25266
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 432 times.
439 if(destscr != -1)
25267 7 currscr = destscr;
25268
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
432 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25269 427 currscr += 16;
25270
25271 439 loadscr(0,destdmap,currscr,scrolldir,overlay);
25272 439 putscr(scrollbuf,0,176,newscr);
25273 439 putscrdoors(scrollbuf,0,176,newscr);
25274 439 sy = 0;
25275
25276
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 40 times.
439 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25277 40 sy+=3;
25278
25279 439 cx = 176 / step;
25280 439 FFCore.init_combo_doscript();
25281 }
25282 439 break;
25283
25284 case left:
25285 {
25286
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 646 times.
648 if(destscr!=-1)
25287 2 currscr = destscr;
25288
3/4
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 641 times.
646 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25289 641 --currscr;
25290
25291 648 loadscr(0,destdmap,currscr,scrolldir,overlay);
25292 648 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
25293 648 putscr(scrollbuf,0,0,newscr);
25294 648 putscrdoors(scrollbuf,0,0,newscr);
25295 648 sx = 256;
25296 648 cx = 256 / step;
25297 648 FFCore.init_combo_doscript();
25298 }
25299 648 break;
25300
25301 case right:
25302 {
25303
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 756 times.
770 if(destscr != -1)
25304 14 currscr = destscr;
25305
2/4
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 756 times.
756 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25306 756 ++currscr;
25307
25308 770 loadscr(0,destdmap,currscr,scrolldir,overlay);
25309 770 putscr(scrollbuf,256,0,newscr);
25310 770 putscrdoors(scrollbuf,256,0,tmpscr);
25311 770 sx = 0;
25312 770 cx = 256 / step;
25313 770 FFCore.init_combo_doscript();
25314 }
25315 770 break;
25316 }
25317
25318 // change Hero's state if entering water
25319 2718 int32_t ahead = lookahead(scrolldir);
25320 2718 int32_t aheadflag = lookaheadflag(scrolldir);
25321 2718 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
25322 2718 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
25323 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25324 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25325 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
25326
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 439 times.
✓ Branch 3 taken 648 times.
✓ Branch 4 taken 770 times.
2718 switch(scrolldir)
25327 {
25328 case up:
25329 861 lookaheady=160;
25330 861 break;
25331
25332 case down:
25333 439 lookaheady=0;
25334 439 break;
25335
25336 case left:
25337 648 lookaheadx=240;
25338 648 break;
25339
25340 case right:
25341 770 lookaheadx=0;
25342 770 break;
25343 }
25344
25345 2718 bool nowinwater = false;
25346
25347
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2707 times.
2718 if(lastaction != inwind)
25348 {
25349
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2677 times.
2707 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
25350 {
25351
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 23 times.
30 if (lookaheadraftflag(scrolldir))
25352 {
25353 23 action=rafting; FFCore.setHeroAction(rafting);
25354 23 raftclk=0;
25355 23 }
25356 30 }
25357
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2647 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 22 times.
2677 else if(iswaterex(ahead, currmap, currscr, -1, lookaheadx,lookaheady) && (current_item(itype_flippers)))
25358 {
25359
9/16
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
22 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
25360 {
25361 21 SetSwim();
25362 21 hopclk = 0xFF;
25363 21 nowinwater = true;
25364 21 }
25365 else
25366 {
25367 1 action=hopping; FFCore.setHeroAction(hopping);
25368 1 hopclk = 2;
25369 1 nowinwater = true;
25370 }
25371 22 }
25372
2/4
✓ Branch 0 taken 2655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2655 times.
✗ Branch 3 not taken.
2655 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
25373 {
25374 action = lastaction; FFCore.setHeroAction(lastaction);
25375 }
25376 else
25377 {
25378 2655 action=none; FFCore.setHeroAction(none);
25379 }
25380 2707 }
25381
25382 // The naturaldark state can be read/set by an FFC script before
25383 // fade() or lighting() is called.
25384 2718 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
25385
25386
2/2
✓ Branch 0 taken 2647 times.
✓ Branch 1 taken 71 times.
2718 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
25387
25388
2/2
✓ Branch 0 taken 2613 times.
✓ Branch 1 taken 105 times.
2718 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
25389 //Preloaded ffc scripts
25390 2718 homescr=currscr;
25391 2718 auto olddmap = currdmap;
25392
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2691 times.
2718 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
25393
25394 2718 currdmap = newdmap;
25395 2718 ffscript_engine(true);
25396 2718 currdmap = olddmap;
25397
25398 // There are two occasions when scrolling must be darkened:
25399 // 1) When scrolling into a dark room.
25400 // 2) When scrolling between DMaps of different colours.
25401
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2691 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
2718 if(destdmap != -1 && DMaps[destdmap].color != currcset)
25402 {
25403 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
25404 darkroom = true;
25405 }
25406
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 2612 times.
2718 else if(!darkroom)
25407 2612 lighting(false, false); // NES behaviour: fade to dark before scrolling
25408
25409
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2688 times.
2718 if(action != rafting) // Is this supposed to be here?!
25410
25411 2688 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
25412
25413 2718 cx *= delay; //so we can have drawing re-done every frame,
25414 //previously it was for(0 to delay) advanceframes at end of loop
25415 2718 int32_t no_move = 0;
25416
25417 2718 currdmap = newdmap;
25418
4/4
✓ Branch 0 taken 2718 times.
✓ Branch 1 taken 223025 times.
✓ Branch 2 taken 223025 times.
✓ Branch 3 taken 2718 times.
225743 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
25419 {
25420
3/4
✓ Branch 0 taken 223025 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101576 times.
✓ Branch 3 taken 121449 times.
223025 if (replay_is_active() && replay_get_version() < 3)
25421 {
25422 121449 replay_poll();
25423 121449 }
25424
1/2
✓ Branch 0 taken 223025 times.
✗ Branch 1 not taken.
223025 if(Quit)
25425 {
25426 screenscrolling = false;
25427 return;
25428 }
25429
25430
25431 223025 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
25432
25433
2/2
✓ Branch 0 taken 206311 times.
✓ Branch 1 taken 16714 times.
223025 if(no_move > 0)
25434 16714 no_move--;
25435
25436 //Don't want to move things on the first or last iteration, or between delays
25437
6/6
✓ Branch 0 taken 220307 times.
✓ Branch 1 taken 2718 times.
✓ Branch 2 taken 216472 times.
✓ Branch 3 taken 3835 times.
✓ Branch 4 taken 9122 times.
✓ Branch 5 taken 207350 times.
223025 if(i == 0 || cx == 0 || cx % delay != 0)
25438 15675 no_move++;
25439
25440
4/4
✓ Branch 0 taken 161917 times.
✓ Branch 1 taken 61108 times.
✓ Branch 2 taken 30772 times.
✓ Branch 3 taken 131145 times.
223025 if(scrolldir == up || scrolldir == down)
25441 {
25442
2/2
✓ Branch 0 taken 78185 times.
✓ Branch 1 taken 13695 times.
91880 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
25443 {
25444 //Add a few extra frames if on the second loop and cool scrolling is not set
25445
2/2
✓ Branch 0 taken 13512 times.
✓ Branch 1 taken 183 times.
13695 if(i == 1)
25446 {
25447 183 cx += (scrolldir == down) ? 3 : 2;
25448 183 no_move += (scrolldir == down) ? 3 : 2;
25449 183 }
25450 13695 }
25451 else
25452 {
25453 //4 frames after we've finished scrolling of being still
25454
4/4
✓ Branch 0 taken 2234 times.
✓ Branch 1 taken 75951 times.
✓ Branch 2 taken 1117 times.
✓ Branch 3 taken 1117 times.
78185 if(cx == 0 && !end_frames)
25455 {
25456 1117 cx += 4;
25457 1117 no_move += 4;
25458 1117 end_frames = true;
25459 1117 }
25460 }
25461 91880 }
25462
25463 //Move Hero and the scroll position
25464
2/2
✓ Branch 0 taken 203593 times.
✓ Branch 1 taken 19432 times.
223025 if(!no_move)
25465 {
25466
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 48842 times.
✓ Branch 2 taken 26442 times.
✓ Branch 3 taken 58301 times.
✓ Branch 4 taken 70008 times.
203593 switch(scrolldir)
25467 {
25468 case up:
25469 48842 sy -= step;
25470 48842 y += step;
25471 48842 break;
25472
25473 case down:
25474 26442 sy += step;
25475 26442 y -= step;
25476 26442 break;
25477
25478 case left:
25479 58301 sx -= step;
25480 58301 x += step;
25481 58301 break;
25482
25483 case right:
25484 70008 sx += step;
25485 70008 x -= step;
25486 70008 break;
25487 }
25488
25489 //bound Hero when me move him off the screen in the last couple of frames of scrolling
25490
2/2
✓ Branch 0 taken 199291 times.
✓ Branch 1 taken 4302 times.
203593 if(y > 160) y = 160;
25491
25492
2/2
✓ Branch 0 taken 201271 times.
✓ Branch 1 taken 2322 times.
203593 if(y < 0) y = 0;
25493
25494
2/2
✓ Branch 0 taken 199952 times.
✓ Branch 1 taken 3641 times.
203593 if(x > 240) x = 240;
25495
25496
2/2
✓ Branch 0 taken 199225 times.
✓ Branch 1 taken 4368 times.
203593 if(x < 0) x = 0;
25497
25498
4/4
✓ Branch 0 taken 203347 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 203337 times.
203593 if(ladderx > 0 || laddery > 0)
25499 {
25500 // If the ladder moves on both axes, the player can
25501 // gradually shift it by going back and forth
25502
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
25503 laddery = y.getInt();
25504 else
25505 256 ladderx = x.getInt();
25506 256 }
25507 203593 }
25508
25509 //Drawing
25510 223025 tx = sx;
25511 223025 ty = sy;
25512 223025 tx2 = sx;
25513 223025 ty2 = sy;
25514
25515
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 71548 times.
✓ Branch 2 taken 30772 times.
✓ Branch 3 taken 59597 times.
✓ Branch 4 taken 61108 times.
223025 switch(scrolldir)
25516 {
25517 case right:
25518 71548 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
25519 71548 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25520 71548 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
25521 71548 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25522 71548 tx -= 256;
25523 71548 break;
25524
25525 case down:
25526 30772 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25527 30772 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
25528 30772 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25529 30772 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
25530 30772 ty -= 176;
25531 30772 break;
25532
25533 case left:
25534 59597 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
25535 59597 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25536 59597 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
25537 59597 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25538 59597 tx2 -= 256;
25539 59597 break;
25540
25541 case up:
25542 61108 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25543 61108 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
25544 61108 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25545 61108 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
25546 61108 ty2 -= 176;
25547 61108 break;
25548 }
25549
25550 //FFScript.OnWaitdraw()
25551 223025 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25552
25553 223025 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
25554 223025 clear_bitmap(scrollbuf);
25555 223025 clear_bitmap(framebuf);
25556
25557
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 61108 times.
✓ Branch 2 taken 30772 times.
✓ Branch 3 taken 59597 times.
✓ Branch 4 taken 71548 times.
223025 switch(scrolldir)
25558 {
25559 case up:
25560
1/2
✓ Branch 0 taken 61108 times.
✗ Branch 1 not taken.
61108 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25561
25562
1/2
✓ Branch 0 taken 61108 times.
✗ Branch 1 not taken.
61108 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
25563
25564
1/2
✓ Branch 0 taken 61108 times.
✗ Branch 1 not taken.
61108 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25565
25566
1/2
✓ Branch 0 taken 61108 times.
✗ Branch 1 not taken.
61108 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
25567
25568 // Draw both screens' background layer primitives together, after both layers' combos.
25569 // Not ideal, but probably good enough for all realistic purposes.
25570
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61108 times.
✓ Branch 2 taken 61108 times.
✗ Branch 3 not taken.
61108 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25571
25572
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61108 times.
✓ Branch 2 taken 61108 times.
✗ Branch 3 not taken.
61108 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25573
25574 61108 putscr(scrollbuf, 0, 0, newscr);
25575 61108 putscr(scrollbuf, 0, 176, oldscr);
25576 61108 break;
25577
25578 case down:
25579
1/2
✓ Branch 0 taken 30772 times.
✗ Branch 1 not taken.
30772 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
25580
25581
1/2
✓ Branch 0 taken 30772 times.
✗ Branch 1 not taken.
30772 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25582
25583
1/2
✓ Branch 0 taken 30772 times.
✗ Branch 1 not taken.
30772 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
25584
25585
1/2
✓ Branch 0 taken 30772 times.
✗ Branch 1 not taken.
30772 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25586
25587
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30772 times.
✓ Branch 2 taken 30772 times.
✗ Branch 3 not taken.
30772 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25588
25589
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30772 times.
✓ Branch 2 taken 30772 times.
✗ Branch 3 not taken.
30772 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25590
25591 30772 putscr(scrollbuf, 0, 0, oldscr);
25592 30772 putscr(scrollbuf, 0, 176, newscr);
25593 30772 break;
25594
25595 case left:
25596
1/2
✓ Branch 0 taken 59597 times.
✗ Branch 1 not taken.
59597 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25597
25598
1/2
✓ Branch 0 taken 59597 times.
✗ Branch 1 not taken.
59597 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
25599
25600
1/2
✓ Branch 0 taken 59597 times.
✗ Branch 1 not taken.
59597 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25601
25602
1/2
✓ Branch 0 taken 59597 times.
✗ Branch 1 not taken.
59597 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
25603
25604
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59597 times.
✓ Branch 2 taken 59597 times.
✗ Branch 3 not taken.
59597 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25605
25606
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59597 times.
✓ Branch 2 taken 59597 times.
✗ Branch 3 not taken.
59597 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25607
25608 59597 putscr(scrollbuf, 0, 0, newscr);
25609 59597 putscr(scrollbuf, 256, 0, oldscr);
25610 59597 break;
25611
25612 case right:
25613
2/2
✓ Branch 0 taken 71416 times.
✓ Branch 1 taken 132 times.
71548 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
25614
25615
2/2
✓ Branch 0 taken 71482 times.
✓ Branch 1 taken 66 times.
71548 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25616
25617
1/2
✓ Branch 0 taken 71548 times.
✗ Branch 1 not taken.
71548 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
25618
25619
1/2
✓ Branch 0 taken 71548 times.
✗ Branch 1 not taken.
71548 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25620
25621
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 71416 times.
✓ Branch 2 taken 71350 times.
✓ Branch 3 taken 198 times.
71548 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25622
25623
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71548 times.
✓ Branch 2 taken 71548 times.
✗ Branch 3 not taken.
71548 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25624
25625 71548 putscr(scrollbuf, 0, 0, oldscr);
25626 71548 putscr(scrollbuf, 256, 0, newscr);
25627 71548 break;
25628 }
25629
25630 223025 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
25631 223025 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
25632
25633 223025 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
25634 223025 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
25635
25636
2/2
✓ Branch 0 taken 222199 times.
✓ Branch 1 taken 826 times.
223025 if(get_bit(quest_rules, qr_FFCSCROLL))
25637 {
25638 826 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
25639 826 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
25640 826 }
25641
25642
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 222959 times.
223025 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
25643
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 222893 times.
223025 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
25644
25645 //push blocks
25646 223025 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
25647 223025 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
25648
2/2
✓ Branch 0 taken 222199 times.
✓ Branch 1 taken 826 times.
223025 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
25649 {
25650 826 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
25651 826 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
25652 826 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
25653 826 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
25654 826 }
25655
25656 223025 do_walkflags(framebuf, oldscr, tx2, ty2,3); //show walkflags if the cheat is on
25657 223025 do_walkflags(framebuf, newscr, tx, ty,2);
25658
25659 223025 do_effectflags(framebuf, oldscr, tx2, ty2,3); //show effectflags if the cheat is on
25660 223025 do_effectflags(framebuf, newscr, tx, ty,2);
25661
25662
25663 223025 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
25664 223025 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
25665 223025 herostep();
25666
25667
4/6
✓ Branch 0 taken 223025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 223025 times.
✓ Branch 4 taken 223025 times.
✓ Branch 5 taken 223025 times.
223025 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
25668 {
25669 446050 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
25670 446050 }
25671
25672
4/4
✓ Branch 0 taken 155046 times.
✓ Branch 1 taken 67979 times.
✓ Branch 2 taken 53038 times.
✓ Branch 3 taken 102008 times.
223025 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
25673 {
25674 121017 draw_under(framebuf); //draw the ladder or raft
25675 121017 decorations.draw2(framebuf, true);
25676 121017 draw(framebuf); //Hero
25677 121017 decorations.draw(framebuf, true);
25678 121017 }
25679
25680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223025 times.
223025 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
25681
25682 223025 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
25683 223025 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
25684
2/2
✓ Branch 0 taken 222199 times.
✓ Branch 1 taken 826 times.
223025 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25685 {
25686 826 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
25687 826 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
25688 826 }
25689 223025 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
25690 223025 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
25691 223025 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
25692
25693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223025 times.
223025 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
25694
25695 223025 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
25696 223025 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
25697
2/2
✓ Branch 0 taken 222199 times.
✓ Branch 1 taken 826 times.
223025 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25698 {
25699 826 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
25700 826 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
25701 826 }
25702 223025 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
25703 223025 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
25704 223025 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
25705
25706
25707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223025 times.
223025 if(msg_bg_display_buf->clip == 0)
25708 {
25709 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25710 }
25711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223025 times.
223025 if(msg_portrait_display_buf->clip == 0)
25712 {
25713 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25714 }
25715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223025 times.
223025 if(msg_txt_display_buf->clip == 0)
25716 {
25717 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25718 }
25719
25720
4/6
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 222199 times.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 826 times.
223025 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
25721 {
25722 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
25723 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
25724 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
25725 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
25726 calc_darkroom_combos(true);
25727 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
25728 }
25729
25730
3/4
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 222199 times.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
223025 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
25731 {
25732 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25733 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25734 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25735 if(newscr->flags & fDARK)
25736 {
25737 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25738 {
25739 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25740 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25741 }
25742
25743 color_map = &trans_table2;
25744 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25745 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25746 else
25747 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25748 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25749 color_map = &trans_table;
25750 }
25751 if(oldscr->flags & fDARK)
25752 {
25753 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25754 {
25755 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25756 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25757 }
25758
25759 color_map = &trans_table2;
25760 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25761 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25762 else
25763 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25764 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25765 color_map = &trans_table;
25766 }
25767 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25768 }
25769 223025 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
25770
2/2
✓ Branch 0 taken 154583 times.
✓ Branch 1 taken 68442 times.
223025 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
25771 68442 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
25772
25773
3/4
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 222199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 826 times.
223025 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
25774 {
25775 826 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25776 826 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25777 826 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25778
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if(newscr->flags & fDARK)
25779 {
25780 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25781 {
25782 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25783 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25784 }
25785
25786 color_map = &trans_table2;
25787 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25788 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25789 else
25790 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25791 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25792 color_map = &trans_table;
25793 }
25794
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if(oldscr->flags & fDARK)
25795 {
25796 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25797 {
25798 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25799 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25800 }
25801
25802 color_map = &trans_table2;
25803 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25804 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25805 else
25806 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25807 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25808 color_map = &trans_table;
25809 }
25810 826 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25811 826 }
25812 223025 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
25813
25814 //end drawing
25815 223025 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25816 223025 advanceframe(true/*,true,false*/);
25817 223025 script_drawing_commands.Clear();
25818 223025 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25819 223025 actiontype lastaction = action;
25820 223025 action=scrolling; FFCore.setHeroAction(scrolling);
25821 223025 FFCore.runF6Engine();
25822 //FFCore.runF6EngineScrolling(newscr,oldscr,tx,ty,tx2,ty2,sx,sy,scrolldir);
25823 223025 action=lastaction; FFCore.setHeroAction(lastaction);
25824 223025 }//end main scrolling loop (2 spaces tab width makes me sad =( )
25825 2718 currdmap = olddmap;
25826
25827 2718 clear_bitmap(msg_txt_display_buf);
25828 2718 set_clip_state(msg_txt_display_buf, 1);
25829 2718 clear_bitmap(msg_bg_display_buf);
25830 2718 set_clip_state(msg_bg_display_buf, 1);
25831 2718 clear_bitmap(msg_portrait_display_buf);
25832 2718 set_clip_state(msg_portrait_display_buf, 1);
25833
25834 //Move hero to the other side of the screen if scrolling's not turned on
25835
1/2
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
2718 if(get_bit(quest_rules, qr_NOSCROLL))
25836 {
25837 switch(scrolldir)
25838 {
25839 case up:
25840 y = 160;
25841 break;
25842
25843 case down:
25844 y = 0;
25845 break;
25846
25847 case left:
25848 x = 240;
25849 break;
25850
25851 case right:
25852 x = 0;
25853 break;
25854 }
25855 }
25856
25857
2/4
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2718 times.
✗ Branch 3 not taken.
2718 if((z > 0 || fakez > 0) && isSideViewHero())
25858 {
25859 y -= z;
25860 y -= fakez;
25861 z = 0;
25862 fakez = 0;
25863 }
25864
25865 2718 set_respawn_point(false);
25866 2718 trySideviewLadder();
25867 2718 warpx = -1;
25868 2718 warpy = -1;
25869
25870 2718 screenscrolling = false;
25871 2718 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
25872 2718 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25873 2718 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25874 2718 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25875 2718 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25876
25877
2/2
✓ Branch 0 taken 2691 times.
✓ Branch 1 taken 27 times.
2718 if(destdmap != -1)
25878 {
25879 27 bool changedlevel = false;
25880 27 bool changeddmap = false;
25881
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 12 times.
27 if(olddmap != destdmap)
25882 {
25883 12 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25884 12 changeddmap = true;
25885 12 }
25886
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
27 if(DMaps[olddmap].level != DMaps[destdmap].level)
25887 {
25888 1 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25889 1 changedlevel = true;
25890 1 }
25891 27 dlevel = DMaps[destdmap].level;
25892 27 currdmap = destdmap;
25893
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 12 times.
27 if(changeddmap)
25894 {
25895 12 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25896 12 }
25897
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
27 if(changedlevel)
25898 {
25899 1 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25900 1 }
25901 27 }
25902
25903 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
25904 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
25905 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
25906 //direction. -DD
25907
25908
2/2
✓ Branch 0 taken 2696 times.
✓ Branch 1 taken 22 times.
2718 if(nowinwater)
25909 {
25910 22 SetSwim();
25911 22 hopclk = 0xFF;
25912 22 }
25913
25914 // NES behaviour: Fade to light after scrolling
25915 2718 lighting(false, false); // No, we don't need to set naturaldark...
25916
25917 2718 init_dmap();
25918 2718 putscr(scrollbuf,0,0,newscr);
25919 2718 putscrdoors(scrollbuf,0,0,newscr);
25920
25921 // Check for raft flags
25922
5/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 2666 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2666 times.
2718 if(action!=rafting && hopclk==0 && !toogam)
25923 {
25924
3/4
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2663 times.
2666 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
25925 {
25926 3 sfx(tmpscr->secretsfx);
25927 3 action=rafting; FFCore.setHeroAction(rafting);
25928 3 raftclk=0;
25929 3 }
25930
25931 // Half a tile off?
25932
6/8
✓ Branch 0 taken 2030 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 758 times.
✓ Branch 3 taken 1272 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1391 times.
✓ Branch 6 taken 2663 times.
✗ Branch 7 not taken.
4054 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
25933 {
25934 sfx(tmpscr->secretsfx);
25935 action=rafting; FFCore.setHeroAction(rafting);
25936 raftclk=0;
25937 }
25938 2666 }
25939
25940 2718 opendoors=0;
25941 2718 markBmap(-1);
25942
25943
2/2
✓ Branch 0 taken 1153 times.
✓ Branch 1 taken 1565 times.
2718 if(isdungeon())
25944 {
25945
3/3
✓ Branch 0 taken 899 times.
✓ Branch 1 taken 373 times.
✓ Branch 2 taken 293 times.
1565 switch(tmpscr->door[scrolldir^1])
25946 {
25947 case dOPEN:
25948 case dUNLOCKED:
25949 case dOPENBOSS:
25950 899 dir = scrolldir;
25951
25952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 899 times.
899 if(action!=rafting)
25953 899 stepforward(diagonalMovement?11:12, false);
25954
25955 899 break;
25956
25957 case dSHUTTER:
25958 case d1WAYSHUTTER:
25959 373 dir = scrolldir;
25960
25961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if(action!=rafting)
25962 373 stepforward(diagonalMovement?21:24, false);
25963
25964 373 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
25965 373 opendoors=-4;
25966 373 sfx(WAV_DOOR);
25967 373 break;
25968
25969 default:
25970 293 dir = scrolldir;
25971
25972
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 291 times.
293 if(action!=rafting)
25973 291 stepforward(diagonalMovement?21:24, false);
25974 293 }
25975 1565 }
25976
25977
1/2
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
2718 if(action == scrolling)
25978 {
25979 action=none; FFCore.setHeroAction(none);
25980 }
25981
25982
2/4
✓ Branch 0 taken 2718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
2718 if(action != attacking && action != sideswimattacking)
25983 {
25984 2718 charging = 0;
25985 2718 tapping = false;
25986 2718 }
25987
25988 2718 map_bkgsfx(true);
25989
25990
2/2
✓ Branch 0 taken 2704 times.
✓ Branch 1 taken 14 times.
2718 if(newscr->flags2&fSECRET)
25991 {
25992 14 sfx(newscr->secretsfx);
25993 14 }
25994
25995 2718 playLevelMusic();
25996
25997 2718 newscr_clk = frame;
25998 2718 activated_timed_warp=false;
25999 2718 loadside = scrolldir^1;
26000 2718 FFCore.init_combo_doscript();
26001 2718 eventlog_mapflags();
26002 2718 decorations.animate(); //continue to animate tall grass during scrolling
26003
2/2
✓ Branch 0 taken 2705 times.
✓ Branch 1 taken 13 times.
2718 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26004 {
26005 //script_drawing_commands.Clear();
26006 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
26007 //ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
26008 13 }
26009 2718 }
26010
26011
26012
26013 // How much to reduce Hero's damage, taking into account various rings.
26014 2307 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
26015 {
26016
1/2
✓ Branch 0 taken 2307 times.
✗ Branch 1 not taken.
2307 if(dmg < 0) return dmg; //Don't reduce healing
26017
2/2
✓ Branch 0 taken 2303 times.
✓ Branch 1 taken 4 times.
2307 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
26018 {
26019 2303 int32_t divisor = 1;
26020 2303 float percentage = 1;
26021 2303 int32_t itemid = current_item_id(itype_ring);
26022 2303 bool usering = false;
26023
26024
4/4
✓ Branch 0 taken 1706 times.
✓ Branch 1 taken 597 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1703 times.
2303 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26025 {
26026 1703 usering = true;
26027 1703 paymagiccost(itemid);
26028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1703 times.
1703 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26029 {
26030 percentage *= itemsbuf[itemid].power/100.0;
26031 }
26032 else
26033 {
26034 1703 divisor *= itemsbuf[itemid].power;
26035 }
26036 1703 }
26037
26038 /* Now for the Peril Ring */
26039 2303 itemid = current_item_id(itype_perilring);
26040
26041
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2303 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26042 {
26043 usering = true;
26044 paymagiccost(itemid);
26045 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26046 {
26047 percentage *= itemsbuf[itemid].power/100.0;
26048 }
26049 else
26050 {
26051 divisor *= itemsbuf[itemid].power;
26052 }
26053 }
26054
26055 // Ring divisor of 0 = no damage. -L
26056
4/6
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 1703 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1703 times.
2303 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26057 return 0;
26058
26059
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
26060
26061
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
26062
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26063
26064 }
26065 else
26066 {
26067 4 double divisor = 1;
26068 4 double percentage = 1;
26069 4 int32_t itemid = current_item_id(itype_ring);
26070 4 bool usering = false;
26071
26072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26073 {
26074 usering = true;
26075 paymagiccost(itemid);
26076 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26077 {
26078 double perc = itemsbuf[itemid].power/100.0;
26079 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26080 percentage *= perc;
26081 }
26082 else
26083 {
26084 if(itemsbuf[itemid].power < 0)
26085 divisor /= -(itemsbuf[itemid].power);
26086 else divisor *= itemsbuf[itemid].power;
26087 }
26088 }
26089
26090 /* Now for the Peril Ring */
26091 4 itemid = current_item_id(itype_perilring);
26092
26093
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26094 {
26095 usering = true;
26096 paymagiccost(itemid);
26097 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26098 {
26099 double perc = itemsbuf[itemid].power/100.0;
26100 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26101 percentage *= perc;
26102 }
26103 else
26104 {
26105 if(itemsbuf[itemid].power < 0)
26106 divisor /= -(itemsbuf[itemid].power);
26107 else divisor *= itemsbuf[itemid].power;
26108 }
26109 }
26110
26111 // Ring divisor of 0 = no damage. -L
26112
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26113 return 0;
26114
26115 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
26116
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26117 }
26118 2307 }
26119
26120 // Should swinging the hammer make the 'pound' sound?
26121 // Or is Hero just hitting air?
26122 bool HeroClass::sideviewhammerpound()
26123 {
26124 int32_t wx=0,wy=0;
26125
26126 switch(dir)
26127 {
26128 case up:
26129 wx=-1;
26130 wy=-15;
26131
26132 if(isSideViewHero()) wy+=8;
26133
26134 break;
26135
26136 case down:
26137 wx=8;
26138 wy=28;
26139
26140 if(isSideViewHero()) wy-=8;
26141
26142 break;
26143
26144 case left:
26145 wx=-8;
26146 wy=14;
26147
26148 if(isSideViewHero()) wy+=8;
26149
26150 break;
26151
26152 case right:
26153 wx=21;
26154 wy=14;
26155
26156 if(isSideViewHero()) wy+=8;
26157
26158 break;
26159 }
26160
26161 if(!isSideViewHero())
26162 {
26163 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
26164 }
26165
26166 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26167
26168 if(dir==left || dir==right)
26169 {
26170 wx+=16;
26171
26172 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26173 }
26174
26175 return false;
26176 }
26177
26178 /************************************/
26179 /******** More Items Code *********/
26180 /************************************/
26181
26182 // The following are only used for Hero damage. Damage is in quarter hearts.
26183 1203 int32_t enemy_dp(int32_t index)
26184 {
26185 1203 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
26186 }
26187
26188 1072 int32_t ewpn_dp(int32_t index)
26189 {
26190 1072 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
26191 }
26192
26193 13 int32_t lwpn_dp(int32_t index)
26194 {
26195 13 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
26196 }
26197
26198 24744915 bool checkbunny(int32_t itemid)
26199 {
26200
1/4
✓ Branch 0 taken 24744915 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24744915 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
26201 }
26202
26203 7633142 bool usesSwordJinx(int32_t itemid)
26204 {
26205 7633142 itemdata const& it = itemsbuf[itemid];
26206 7633142 bool ret = (it.family==itype_sword);
26207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7633142 times.
7633142 if(it.flags & ITEM_FLIP_JINX) return !ret;
26208 7633142 return ret;
26209 7633142 }
26210 6572263 bool checkitem_jinx(int32_t itemid)
26211 {
26212 6572263 itemdata const& it = itemsbuf[itemid];
26213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6572263 times.
6572263 if(it.flags & ITEM_JINX_IMMUNE) return true;
26214
2/2
✓ Branch 0 taken 1828307 times.
✓ Branch 1 taken 4743956 times.
6572263 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
26215 4743956 return HeroItemClk() == 0;
26216 6572263 }
26217
26218 69582 int32_t Bweapon(int32_t pos)
26219 {
26220
3/4
✓ Branch 0 taken 69582 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 369 times.
✓ Branch 3 taken 69213 times.
69582 if(pos < 0 || current_subscreen_active == NULL)
26221 {
26222 369 return 0;
26223 }
26224
26225 69213 int32_t p=-1;
26226
26227
4/4
✓ Branch 0 taken 21709 times.
✓ Branch 1 taken 1747122 times.
✓ Branch 2 taken 21709 times.
✓ Branch 3 taken 1747122 times.
1768831 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
26228 {
26229
4/4
✓ Branch 0 taken 1139390 times.
✓ Branch 1 taken 607732 times.
✓ Branch 2 taken 1091886 times.
✓ Branch 3 taken 47504 times.
1747122 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
26230 {
26231 47504 p=i;
26232 47504 break;
26233 }
26234 1699618 }
26235
26236
2/2
✓ Branch 0 taken 47504 times.
✓ Branch 1 taken 21709 times.
69213 if(p==-1)
26237 {
26238 21709 return 0;
26239 }
26240
26241 47504 int32_t actualItem = current_subscreen_active->objects[p].d8;
26242 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
26243 47504 int32_t family = -1;
26244 47504 bool bow = false;
26245
26246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47504 times.
47504 if(actualItem)
26247 {
26248 bool select = false;
26249
26250 switch(itemsbuf[actualItem-1].family)
26251 {
26252 case itype_bomb:
26253 if((game->get_bombs() ||
26254 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26255 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
26256 current_item_power(itype_bombbag))
26257 {
26258 select=true;
26259 }
26260
26261 break;
26262
26263 case itype_bowandarrow:
26264 case itype_arrow:
26265 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
26266 {
26267 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26268 select=true;
26269 }
26270
26271 break;
26272
26273 case itype_letterpotion:
26274 /*if(current_item_id(itype_potion)>-1)
26275 {
26276 select=true;
26277 }
26278 else if(current_item_id(itype_letter)>-1)
26279 {
26280 select=true;
26281 }*/
26282 break;
26283
26284 case itype_sbomb:
26285 {
26286 int32_t bombbagid = current_item_id(itype_bombbag);
26287
26288 if((game->get_sbombs() ||
26289 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26290 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
26291 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26292 {
26293 select=true;
26294 }
26295
26296 break;
26297 }
26298
26299 case itype_sword:
26300 {
26301 if(!get_bit(quest_rules,qr_SELECTAWPN))
26302 break;
26303
26304 select=true;
26305 }
26306 break;
26307
26308 default:
26309 select=true;
26310 }
26311
26312 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
26313 {
26314 directItem = actualItem-1;
26315
26316 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
26317
26318 return actualItem-1+(bow?0xF000:0);
26319 }
26320 else return 0;
26321 }
26322
26323 47504 directItem = -1;
26324
26325
5/6
✓ Branch 0 taken 6542 times.
✓ Branch 1 taken 765 times.
✓ Branch 2 taken 36770 times.
✓ Branch 3 taken 2109 times.
✓ Branch 4 taken 1318 times.
✗ Branch 5 not taken.
47504 switch(current_subscreen_active->objects[p].d1)
26326 {
26327 case itype_bomb:
26328 {
26329 6542 int32_t bombid = current_item_id(itype_bomb);
26330
26331
3/4
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 6241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 301 times.
6843 if((game->get_bombs() ||
26332 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26333
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 279 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
301 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
26334 301 current_item_power(itype_bombbag))
26335 {
26336 6241 family=itype_bomb;
26337 6241 }
26338
26339 6542 break;
26340 }
26341
26342 case itype_bowandarrow:
26343 case itype_arrow:
26344
3/4
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 432 times.
✓ Branch 2 taken 1677 times.
✗ Branch 3 not taken.
2109 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
26345 {
26346 1677 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26347 1677 family=itype_arrow;
26348 1677 }
26349
26350 2109 break;
26351
26352 case itype_letterpotion:
26353
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 497 times.
1318 if(current_item_id(itype_potion)>-1)
26354 {
26355 821 family=itype_potion;
26356 821 }
26357
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 136 times.
497 else if(current_item_id(itype_letter)>-1)
26358 {
26359 136 family=itype_letter;
26360 136 }
26361
26362 1318 break;
26363
26364 case itype_sbomb:
26365 {
26366 765 int32_t bombbagid = current_item_id(itype_bombbag);
26367 765 int32_t sbombid = current_item_id(itype_sbomb);
26368
26369
2/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
765 if((game->get_sbombs() ||
26370 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
26372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26373 {
26374 730 family=itype_sbomb;
26375 730 }
26376
26377 765 break;
26378 }
26379
26380 case itype_sword:
26381 {
26382 if(!get_bit(quest_rules,qr_SELECTAWPN))
26383 break;
26384
26385 family=itype_sword;
26386 }
26387 break;
26388
26389 default:
26390 36770 family=current_subscreen_active->objects[p].d1;
26391 36770 }
26392
26393
2/2
✓ Branch 0 taken 46375 times.
✓ Branch 1 taken 1129 times.
47504 if(family==-1)
26394 1129 return 0;
26395
26396
2/2
✓ Branch 0 taken 1588345 times.
✓ Branch 1 taken 2218 times.
1590563 for(int32_t j=0; j<MAXITEMS; j++)
26397 {
26398 // Find the item that matches this subscreen object.
26399
5/6
✓ Branch 0 taken 67639 times.
✓ Branch 1 taken 1520706 times.
✓ Branch 2 taken 44157 times.
✓ Branch 3 taken 23482 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44157 times.
1588345 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
26400 {
26401 44157 return j+(bow?0xF000:0);
26402 }
26403 1544188 }
26404
26405 2218 return 0;
26406 69582 }
26407
26408 int32_t BWeapon_to_Pos(int32_t bweapon)
26409 {
26410 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
26411 {
26412 if (Bweapon(i) == bweapon)
26413 {
26414 return i;
26415 }
26416 }
26417 return -1;
26418 }
26419
26420 void stopCaneOfByrna()
26421 {
26422 for(int32_t i=0; i<Lwpns.Count(); i++)
26423 {
26424 weapon *w = ((weapon*)Lwpns.spr(i));
26425 if(w->id==wCByrna)
26426 w->dead=1;
26427 }
26428 }
26429
26430 /* Crashes if used by ffscript.cpp, in case LINKITEMD
26431 void stopCaneOfByrna()
26432 {
26433 byte prnt_cane = -1;
26434 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
26435 prnt_cane = ew->parentitem;
26436 for(int32_t i=0; i<Lwpns.Count(); i++)
26437 {
26438 weapon *w = ((weapon*)Lwpns.spr(i));
26439
26440 if(w->id==wCByrna)
26441 {
26442 w->dead=1;
26443 }
26444 }
26445 if ( prnt_cane > -1 )
26446 {
26447 stop_sfx(itemsbuf[prnt_cane].usesound);
26448 }
26449 }
26450 */
26451 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
26452 1980334 void HeroClass::cleanupByrna()
26453 {
26454
1/2
✓ Branch 0 taken 1980334 times.
✗ Branch 1 not taken.
1980334 if ( last_cane_of_byrna_item_id > -1 )
26455 {
26456 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
26457 if ( !(Lwpns.idCount(wCByrna)) )
26458 {
26459 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
26460 last_cane_of_byrna_item_id = -1;
26461 }
26462 }
26463 1980334 }
26464
26465 // Used to find out if an item family is attached to one of the buttons currently pressed.
26466 431284 bool isWpnPressed(int32_t itype)
26467 {
26468 //0xFFF for subscreen overrides
26469 //Will crash on win10 without it! -Z
26470
4/4
✓ Branch 0 taken 12196 times.
✓ Branch 1 taken 419088 times.
✓ Branch 2 taken 6958 times.
✓ Branch 3 taken 5238 times.
431284 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
26471
4/4
✓ Branch 0 taken 308138 times.
✓ Branch 1 taken 117908 times.
✓ Branch 2 taken 82093 times.
✓ Branch 3 taken 226045 times.
426046 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
26472
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 200001 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200001 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
26473
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 200001 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200001 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
26474 200001 return false;
26475 431284 }
26476
26477 1907629 int32_t getWpnPressed(int32_t itype)
26478 {
26479
4/4
✓ Branch 0 taken 5433 times.
✓ Branch 1 taken 1902196 times.
✓ Branch 2 taken 5112 times.
✓ Branch 3 taken 321 times.
1907629 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26480
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1907308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1907308 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1907308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1907308 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1907308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1907308 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26483
26484 1907308 return -1;
26485 1907629 }
26486
26487 bool isItmPressed(int32_t itmid)
26488 {
26489 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
26490 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
26491 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
26492 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
26493 return false;
26494 }
26495
26496 void selectNextAWpn(int32_t type)
26497 {
26498 if(!get_bit(quest_rules,qr_SELECTAWPN))
26499 return;
26500
26501 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26502 Awpn = Bweapon(ret);
26503 directItemA = directItem;
26504 game->awpn = ret;
26505 }
26506
26507 1612 void selectNextBWpn(int32_t type)
26508 {
26509
2/4
✓ Branch 0 taken 1612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1612 times.
1612 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26510 1612 Bwpn = Bweapon(ret);
26511 1612 directItemB = directItem;
26512 1612 game->bwpn = ret;
26513 1612 }
26514
26515 void selectNextXWpn(int32_t type)
26516 {
26517 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
26518 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26519 Xwpn = Bweapon(ret);
26520 directItemX = directItem;
26521 game->xwpn = ret;
26522 }
26523
26524 void selectNextYWpn(int32_t type)
26525 {
26526 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
26527 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
26528 Ywpn = Bweapon(ret);
26529 directItemY = directItem;
26530 game->ywpn = ret;
26531 }
26532
26533 11766 void verifyAWpn()
26534 {
26535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11766 times.
11766 if ( (game->forced_awpn != -1) )
26536 {
26537 return;
26538 }
26539
1/2
✓ Branch 0 taken 11766 times.
✗ Branch 1 not taken.
11766 if(!get_bit(quest_rules,qr_SELECTAWPN))
26540 {
26541 11766 Awpn = selectSword();
26542 11766 game->awpn = 0xFF;
26543 11766 }
26544 else
26545 {
26546 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
26547 Awpn = Bweapon(game->awpn);
26548 directItemA = directItem;
26549 }
26550 11766 }
26551
26552 10851 void verifyBWpn()
26553 {
26554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10851 times.
10851 if ( (game->forced_bwpn != -1) )
26555 {
26556 return;
26557 }
26558 10851 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
26559 10851 Bwpn = Bweapon(game->bwpn);
26560 10851 directItemB = directItem;
26561 10851 }
26562
26563 10851 void verifyXWpn()
26564 {
26565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10851 times.
10851 if ( (game->forced_xwpn != -1) )
26566 {
26567 return;
26568 }
26569
1/2
✓ Branch 0 taken 10851 times.
✗ Branch 1 not taken.
10851 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
26570 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
26571 10851 else game->xwpn = -1;
26572 10851 Xwpn = Bweapon(game->xwpn);
26573 10851 directItemX = directItem;
26574 10851 }
26575
26576 10851 void verifyYWpn()
26577 {
26578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10851 times.
10851 if ( (game->forced_ywpn != -1) )
26579 {
26580 return;
26581 }
26582
1/2
✓ Branch 0 taken 10851 times.
✗ Branch 1 not taken.
10851 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
26583 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
26584 10851 else game->ywpn = -1;
26585 10851 Ywpn = Bweapon(game->ywpn);
26586 10851 directItemY = directItem;
26587 10851 }
26588
26589 10851 void verifyBothWeapons()
26590 {
26591 10851 verifyAWpn();
26592 10851 verifyBWpn();
26593 10851 verifyXWpn();
26594 10851 verifyYWpn();
26595 10851 }
26596
26597 13215 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
26598 {
26599 //what will be returned when all else fails.
26600 //don't return the forbiddenpos... no matter what -DD
26601
26602 13215 int32_t failpos(0);
26603
26604
5/6
✓ Branch 0 taken 12950 times.
✓ Branch 1 taken 265 times.
✓ Branch 2 taken 12939 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12939 times.
13215 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
26605 276 failpos = 0xFF;
26606 12939 else failpos = startpos;
26607
26608 // verify startpos
26609
3/4
✓ Branch 0 taken 13215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 12937 times.
13215 if(startpos < 0 || startpos >= 0xFF)
26610 278 startpos = 0;
26611
26612
2/2
✓ Branch 0 taken 13092 times.
✓ Branch 1 taken 123 times.
13215 if(current_subscreen_active == NULL)
26613 123 return failpos;
26614
26615
4/4
✓ Branch 0 taken 2303 times.
✓ Branch 1 taken 10789 times.
✓ Branch 2 taken 359 times.
✓ Branch 3 taken 1944 times.
13092 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
26616 {
26617 11148 int32_t wpn = Bweapon(startpos);
26618
26619
5/8
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 291 times.
✓ Branch 2 taken 10857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10857 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 10857 times.
11148 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
26620 {
26621 10857 return startpos;
26622 }
26623 291 }
26624
26625 2235 int32_t p=-1;
26626 2235 int32_t curpos = startpos;
26627 2235 int32_t firstValidPos=-1;
26628
26629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50289 times.
50289 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26630 {
26631
2/2
✓ Branch 0 taken 18067 times.
✓ Branch 1 taken 32222 times.
50289 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26632 {
26633
4/4
✓ Branch 0 taken 27596 times.
✓ Branch 1 taken 4626 times.
✓ Branch 2 taken 25361 times.
✓ Branch 3 taken 2235 times.
32222 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
26634 {
26635 2235 firstValidPos=i;
26636 2235 }
26637
26638
2/2
✓ Branch 0 taken 29987 times.
✓ Branch 1 taken 2235 times.
32222 if(current_subscreen_active->objects[i].d3==curpos)
26639 {
26640 2235 p=i;
26641 2235 break;
26642 }
26643 29987 }
26644 48054 }
26645
26646
1/2
✓ Branch 0 taken 2235 times.
✗ Branch 1 not taken.
2235 if(p == -1)
26647 {
26648 //can't find the current position
26649 // Switch to a valid weapon if there is one; otherwise,
26650 // the selector can simply disappear
26651 if(firstValidPos>=0)
26652 {
26653 return current_subscreen_active->objects[firstValidPos].d3;
26654 }
26655 //FAILURE
26656 else
26657 {
26658 return failpos;
26659 }
26660 }
26661
26662 //remember we've been here
26663 2235 set<int32_t> oldPositions;
26664
1/2
✓ Branch 0 taken 2235 times.
✗ Branch 1 not taken.
2235 oldPositions.insert(curpos);
26665
26666 //1. Perform any shifts required by the above
26667 //2. If that's not possible, go to position 1 and reset the b weapon.
26668 //2a. -if we arrive at a position we've already visited, give up and stay there
26669 //3. Get the weapon at the new slot
26670 //4. If it's not possible, go to step 1.
26671
26672 5085 for(;;)
26673 {
26674 //shift
26675
4/5
✓ Branch 0 taken 1299 times.
✓ Branch 1 taken 3746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 36 times.
5085 switch(type)
26676 {
26677 case SEL_LEFT:
26678 case SEL_VERIFY_LEFT:
26679 1299 curpos = current_subscreen_active->objects[p].d6;
26680 1299 break;
26681
26682 case SEL_RIGHT:
26683 case SEL_VERIFY_RIGHT:
26684 3746 curpos = current_subscreen_active->objects[p].d7;
26685 3746 break;
26686
26687 case SEL_DOWN:
26688 4 curpos = current_subscreen_active->objects[p].d5;
26689 4 break;
26690
26691 case SEL_UP:
26692 36 curpos = current_subscreen_active->objects[p].d4;
26693 36 break;
26694 }
26695
26696 //find our new position
26697 5085 p = -1;
26698
26699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126262 times.
126262 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26700 {
26701
2/2
✓ Branch 0 taken 41551 times.
✓ Branch 1 taken 84711 times.
126262 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26702 {
26703
2/2
✓ Branch 0 taken 79626 times.
✓ Branch 1 taken 5085 times.
84711 if(current_subscreen_active->objects[i].d3==curpos)
26704 {
26705 5085 p=i;
26706 5085 break;
26707 }
26708 79626 }
26709 121177 }
26710
26711
1/2
✓ Branch 0 taken 5085 times.
✗ Branch 1 not taken.
5085 if(p == -1)
26712 {
26713 //can't find the current position
26714 //FAILURE
26715 return failpos;
26716 }
26717
26718 //if we've already been here, give up
26719
4/6
✓ Branch 0 taken 5085 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5085 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4808 times.
✓ Branch 5 taken 277 times.
5085 if(oldPositions.find(curpos) != oldPositions.end())
26720 {
26721 277 return failpos;
26722 }
26723
26724 //else, remember we've been here
26725
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 oldPositions.insert(curpos);
26726
26727 //see if this weapon is acceptable
26728
6/10
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1958 times.
✓ Branch 3 taken 2850 times.
✓ Branch 4 taken 1958 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1958 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1958 times.
4808 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
26729 1958 return curpos;
26730
26731 //keep going otherwise
26732 }
26733 13215 }
26734
26735 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
26736 11827 int32_t selectSword()
26737 {
26738 11827 auto ret = current_item_id(itype_sword);
26739
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 11594 times.
11827 if(ret == -1) return 0;
26740 11594 return ret;
26741 11827 }
26742
26743 // Adding code here for allowing hardcoding a button to a specific itemclass.
26744 int32_t selectItemclass(int32_t itemclass)
26745 {
26746 int32_t ret = current_item_id(itemclass);
26747
26748 if(ret == -1)
26749 ret = 0;
26750
26751 return ret;
26752 }
26753
26754 // Used for the 'Pickup Hearts' item pickup condition.
26755 26 bool canget(int32_t id)
26756 {
26757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
26758 }
26759
26760 20 void dospecialmoney(int32_t index)
26761 {
26762 20 int32_t tmp=currscr>=128?1:0;
26763 20 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
26764
26765
3/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
20 switch(tmpscr[tmp].room)
26766 {
26767 case rINFO: // pay for info
26768 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
26769 {
26770
26771
26772 if(!current_item_power(itype_wallet))
26773 {
26774 if (game->get_spendable_rupies() < abs(prices[priceindex]))
26775 return;
26776 int32_t tmpprice = -abs(prices[priceindex]);
26777 int32_t total = game->get_drupy()-tmpprice;
26778 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26779 game->set_drupy(game->get_drupy()-total);
26780 //game->change_drupy(-abs(prices[priceindex]));
26781 }
26782 if ( current_item_power(itype_wallet)>0 )
26783 {
26784 game->change_drupy(0);
26785 }
26786 }
26787 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
26788 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
26789 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
26790 clear_bitmap(pricesdisplaybuf);
26791 set_clip_state(pricesdisplaybuf, 1);
26792 items.del(0);
26793
26794 for(int32_t i=0; i<items.Count(); i++)
26795 ((item*)items.spr(i))->pickup=ipDUMMY;
26796
26797 // Prevent the prices from being displayed anymore
26798 for(int32_t i=0; i<3; i++)
26799 {
26800 prices[i] = 0;
26801 }
26802
26803 break;
26804
26805 case rMONEY: // secret money
26806 {
26807 9 ((item*)items.spr(0))->pickup = ipDUMMY;
26808
26809 9 prices[0] = tmpscr[tmp].catchall;
26810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!current_item_power(itype_wallet))
26811 9 game->change_drupy(prices[0]);
26812 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
26813
26814 9 putprices(false);
26815
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26816 9 break;
26817 }
26818
26819 case rGAMBLE: // gamble
26820 {
26821 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
26822
26823 unsigned si=(zc_oldrand()%24)*3;
26824
26825 for(int32_t i=0; i<3; i++)
26826 prices[i]=gambledat[si++];
26827
26828 game->set_drupy(game->get_drupy()+prices[priceindex]);
26829 putprices(true);
26830
26831 for(int32_t i=1; i<4; i++)
26832 ((item*)items.spr(i))->pickup=ipDUMMY;
26833 }
26834 break;
26835
26836 case rBOMBS:
26837 {
26838
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26839 return;
26840
26841 3 int32_t price = -tmpscr[tmp].catchall;
26842 3 int32_t wmedal = current_item_id(itype_wealthmedal);
26843
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(wmedal >= 0)
26844 {
26845 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26846 price*=(itemsbuf[wmedal].misc1/100.0);
26847 else
26848 price+=itemsbuf[wmedal].misc1;
26849 }
26850
26851 3 int32_t total = game->get_drupy()-price;
26852 3 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26853 3 game->set_drupy(game->get_drupy()-total);
26854 //game->set_drupy(game->get_drupy()+price);
26855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26856 3 game->change_maxbombs(4);
26857 3 game->set_bombs(game->get_maxbombs());
26858 {
26859 3 int32_t div = zinit.bomb_ratio;
26860
26861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(div > 0)
26862 3 game->change_maxcounter(4/div, 6);
26863 }
26864
26865 //also give Hero an actual Bomb item
26866
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
26867 {
26868
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 763 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
768 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
26869 3 getitem(i, true, true);
26870 768 }
26871
26872 3 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
26873 3 fadeclk=66;
26874 3 dismissmsg();
26875 3 clear_bitmap(pricesdisplaybuf);
26876 3 set_clip_state(pricesdisplaybuf, 1);
26877 // putscr(scrollbuf,0,0,tmpscr);
26878 3 verifyBothWeapons();
26879 3 break;
26880 }
26881
26882 case rARROWS:
26883 {
26884 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26885 return;
26886
26887 int32_t price = -tmpscr[tmp].catchall;
26888 int32_t wmedal = current_item_id(itype_wealthmedal);
26889 if(wmedal >= 0)
26890 {
26891 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26892 price*=(itemsbuf[wmedal].misc1/100.0);
26893 else
26894 price+=itemsbuf[wmedal].misc1;
26895 }
26896
26897 int32_t total = game->get_drupy()-price;
26898 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26899 game->set_drupy(game->get_drupy()-total);
26900
26901 //game->set_drupy(game->get_drupy()+price);
26902 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26903 game->change_maxarrows(10);
26904 game->set_arrows(game->get_maxarrows());
26905 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
26906 fadeclk=66;
26907 dismissmsg();
26908 clear_bitmap(pricesdisplaybuf);
26909 set_clip_state(pricesdisplaybuf, 1);
26910 // putscr(scrollbuf,0,0,tmpscr);
26911 verifyBothWeapons();
26912 break;
26913 }
26914
26915 case rSWINDLE:
26916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(items.spr(index)->id==iRupy)
26917 {
26918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26919 return;
26920 8 int32_t tmpprice = -tmpscr[tmp].catchall;
26921 8 int32_t total = game->get_drupy()-tmpprice;
26922 8 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26923 8 game->set_drupy(game->get_drupy()-total);
26924 8 }
26925 else
26926 {
26927 if(game->get_maxlife()<=game->get_hp_per_heart())
26928 return;
26929
26930 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
26931 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
26932 }
26933
26934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26935 8 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
26936 8 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
26937 8 fadeclk=66;
26938 8 dismissmsg();
26939 8 clear_bitmap(pricesdisplaybuf);
26940 8 set_clip_state(pricesdisplaybuf, 1);
26941 // putscr(scrollbuf,0,0,tmpscr);
26942 8 break;
26943 }
26944 20 }
26945
26946 3599 void getitem(int32_t id, bool nosound, bool doRunPassive)
26947 {
26948
1/2
✓ Branch 0 taken 3599 times.
✗ Branch 1 not taken.
3599 if(id<0)
26949 {
26950 return;
26951 }
26952
26953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3599 times.
3599 if (replay_is_active())
26954
1/2
✓ Branch 0 taken 3599 times.
✗ Branch 1 not taken.
3599 replay_step_comment(fmt::format("getitem {}", item_string[id]));
26955
26956
2/2
✓ Branch 0 taken 3596 times.
✓ Branch 1 taken 3 times.
3599 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
26957 {
26958 3 int32_t nextitem = -1;
26959 3 do
26960 {
26961 3 nextitem = -1;
26962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
26963 // Item upgrade routine.
26964 {
26965
26966 for(int32_t i=0; i<MAXITEMS; i++)
26967 {
26968 // Find the item which is as close to this item's fam_type as possible.
26969 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
26970 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
26971 {
26972 nextitem = i;
26973 }
26974 }
26975
26976 if(nextitem>-1)
26977 {
26978 id = nextitem;
26979 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
26980 break; //no looping
26981 }
26982 }
26983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } while(nextitem > -1);
26984 3 }
26985
26986 3599 itemdata const& idat = itemsbuf[id&0xFF];
26987 // if(idat.family!=0xFF) //1.92 compat... that already should be changed to 'itype_misc'? Blehg, hate this! -Em
26988 {
26989
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3304 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 265 times.
3599 if(idat.flags & ITEM_GAMEDATA && idat.family != itype_triforcepiece)
26990 {
26991 // Fix boomerang sounds.
26992 265 int32_t itemid = current_item_id(idat.family);
26993
26994
4/6
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 153 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
265 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_nayruslove
26995
3/6
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✗ Branch 5 not taken.
153 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
26996 157 && sfx_allocated(itemsbuf[itemid].usesound)
26997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 && idat.usesound != itemsbuf[itemid].usesound)
26998 {
26999 stop_sfx(itemsbuf[itemid].usesound);
27000 cont_sfx(idat.usesound);
27001 }
27002
27003 265 int32_t curitm = current_item_id(idat.family);
27004
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
265 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
27005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
265 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
27006 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
27007 {
27008 265 game->set_item(id,true);
27009 265 passiveitem_script(id, doRunPassive);
27010 265 }
27011
27012
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 236 times.
265 if(!(idat.flags & ITEM_KEEPOLD))
27013 {
27014
3/4
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234 times.
236 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
27015 {
27016 2 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
27017 2 }
27018 236 }
27019
27020 // NES consistency: replace all flying boomerangs with the current boomerang.
27021
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 11 times.
265 if(idat.family==itype_brang)
27022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 for(int32_t i=0; i<Lwpns.Count(); i++)
27023 {
27024 weapon *w = ((weapon*)Lwpns.spr(i));
27025
27026 if(w->id==wBrang)
27027 {
27028 w->LOADGFX(idat.wpn);
27029 }
27030 11 }
27031 265 }
27032
27033
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 3074 times.
3599 if(idat.count!=-1)
27034 {
27035
2/2
✓ Branch 0 taken 3018 times.
✓ Branch 1 taken 56 times.
3074 if(idat.setmax)
27036 {
27037 // Bomb bags are a special case; they may be set not to increase super bombs
27038
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
56 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
27039 {
27040 int32_t max = game->get_maxbombs();
27041
27042 if(max<idat.max) max=idat.max;
27043
27044 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
27045 }
27046 else
27047 {
27048 56 int32_t max = game->get_maxcounter(idat.count);
27049
27050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(max<idat.max) max=idat.max;
27051
27052
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 6 times.
56 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
27053 }
27054 56 }
27055
27056 // Amount is an uint16_t, but the range is -9999 to 16383
27057 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
27058
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3044 times.
3074 if(idat.amount&0x3FFF)
27059 {
27060
2/2
✓ Branch 0 taken 2072 times.
✓ Branch 1 taken 972 times.
3044 if(idat.amount&0x8000)
27061 4144 game->set_dcounter(
27062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2072 times.
2072 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27063 else
27064 {
27065
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
972 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
27066 game->set_counter(0, idat.count);
27067 else
27068 // This is too confusing to try and change...
27069
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 499 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 473 times.
972 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
27070 }
27071 3044 }
27072 3074 }
27073 }
27074
27075
3/4
✓ Branch 0 taken 3599 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3571 times.
3599 if(idat.playsound&&!nosound)
27076 {
27077 3571 sfx(idat.playsound);
27078 3571 }
27079
27080 //add lower-level items
27081
2/2
✓ Branch 0 taken 3588 times.
✓ Branch 1 taken 11 times.
3599 if(idat.flags&ITEM_GAINOLD)
27082 {
27083
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11 times.
21 for(int32_t i=idat.fam_type-1; i>0; i--)
27084 {
27085 10 int32_t potid = getItemID(itemsbuf, idat.family, i);
27086
27087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(potid != -1)
27088 {
27089 10 game->set_item(potid, true);
27090 10 }
27091 10 }
27092 11 }
27093
27094
9/14
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3195 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 22 times.
✓ Branch 10 taken 17 times.
✓ Branch 11 taken 142 times.
✓ Branch 12 taken 8 times.
✗ Branch 13 not taken.
3599 switch(idat.family)
27095 {
27096 case itype_itmbundle:
27097 {
27098 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27099 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27100 bool pscript = (idat.flags & ITEM_FLAG1);
27101 for(auto q = 0; q < 10; ++q)
27102 {
27103 if(unsigned(ids[q]) >= MAXITEMS) continue;
27104 if(pscript)
27105 collectitem_script(ids[q]);
27106 getitem(ids[q], true, true);
27107 }
27108 }
27109 break;
27110
27111 case itype_progressive_itm:
27112 {
27113 int32_t newid = get_progressive_item(idat);
27114 if(newid > -1)
27115 getitem(newid, nosound, true);
27116 }
27117 break;
27118
27119 case itype_bottlefill:
27120 {
27121 if(idat.misc1)
27122 {
27123 game->fillBottle(idat.misc1);
27124 }
27125 }
27126 break;
27127
27128 case itype_clock:
27129 {
27130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27131 break;
27132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
27133 break;
27134 160 setClock(watch=true);
27135
27136
2/2
✓ Branch 0 taken 81920 times.
✓ Branch 1 taken 160 times.
82080 for(int32_t i=0; i<eMAXGUYS; i++)
27137 81920 clock_zoras[i]=0;
27138
27139 160 clockclk=itemsbuf[id&0xFF].misc1;
27140 160 sfx(idat.usesound);
27141 }
27142 160 break;
27143
27144 case itype_lkey:
27145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
27146 25 break;
27147
27148 case itype_ring:
27149 case itype_magicring:
27150
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
6 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27151 {
27152 6 ringcolor(false);
27153 6 }
27154 6 break;
27155
27156 case itype_whispring:
27157 {
27158 if(idat.flags & ITEM_FLAG1)
27159 {
27160 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
27161
27162 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
27163 }
27164
27165 if(idat.power==0)
27166 {
27167 setSwordClk(0);
27168 setItemClk(0);
27169 }
27170
27171 break;
27172 }
27173
27174
27175 case itype_map:
27176 24 game->lvlitems[dlevel]|=liMAP;
27177 24 break;
27178
27179 case itype_compass:
27180 22 game->lvlitems[dlevel]|=liCOMPASS;
27181 22 break;
27182
27183 case itype_bosskey:
27184 17 game->lvlitems[dlevel]|=liBOSSKEY;
27185 17 break;
27186
27187 case itype_fairy:
27188
27189
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 87 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
142 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
27190
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
142 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
27191 142 break;
27192
27193 case itype_heartpiece:
27194 8 game->change_HCpieces(1);
27195
27196
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(game->get_HCpieces()<game->get_hcp_per_hc())
27197 6 break;
27198
27199 2 game->set_HCpieces(0);
27200
27201 2 getitem(heart_container_id());
27202 2 break;
27203
27204 case itype_killem:
27205 {
27206 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27207 break;
27208 kill_em_all();
27209 sfx(idat.usesound);
27210 }
27211 break;
27212 }
27213
27214 3599 update_subscreens();
27215 3599 load_Sitems(&QMisc);
27216 3599 verifyBothWeapons();
27217 3599 }
27218
27219 void takeitem(int32_t id)
27220 {
27221 game->set_item(id, false);
27222 itemdata const& idat = itemsbuf[id];
27223
27224 /* Lower the counters! */
27225 if(idat.count!=-1)
27226 {
27227 if(idat.setmax)
27228 {
27229 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
27230 }
27231
27232 if(idat.amount&0x3FFF)
27233 {
27234 if(idat.amount&0x8000)
27235 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27236 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27237 }
27238 }
27239
27240 switch(itemsbuf[id&0xFF].family)
27241 {
27242 // NES consistency: replace all flying boomerangs with the current boomerang.
27243 case itype_brang:
27244 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
27245 {
27246 weapon *w = ((weapon*)Lwpns.spr(i));
27247
27248 if(w->id==wBrang)
27249 {
27250 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
27251 }
27252 }
27253
27254 break;
27255
27256 case itype_itmbundle:
27257 {
27258 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27259 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27260 for(auto q = 0; q < 10; ++q)
27261 {
27262 if(unsigned(ids[q]) >= MAXITEMS) continue;
27263 takeitem(ids[q]);
27264 }
27265 }
27266 break;
27267
27268 case itype_progressive_itm:
27269 {
27270 int32_t newid = get_progressive_item(idat, true);
27271 if(newid > -1)
27272 takeitem(newid);
27273 }
27274 break;
27275
27276 case itype_heartpiece:
27277 if(game->get_maxlife()>game->get_hp_per_heart())
27278 {
27279 if(game->get_HCpieces()==0)
27280 {
27281 game->set_HCpieces(game->get_hcp_per_hc());
27282 takeitem(iHeartC);
27283 }
27284
27285 game->change_HCpieces(-1);
27286 }
27287 break;
27288
27289 case itype_map:
27290 game->lvlitems[dlevel]&=~liMAP;
27291 break;
27292
27293 case itype_compass:
27294 game->lvlitems[dlevel]&=~liCOMPASS;
27295 break;
27296
27297 case itype_bosskey:
27298 game->lvlitems[dlevel]&=~liBOSSKEY;
27299 break;
27300
27301 case itype_lkey:
27302 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
27303 break;
27304
27305 case itype_ring:
27306 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27307 {
27308 ringcolor(false);
27309 }
27310 break;
27311 }
27312 }
27313
27314 // Attempt to pick up an item. (-1 = check items touching Hero.)
27315 1980749 void HeroClass::checkitems(int32_t index)
27316 {
27317 1980749 int32_t tmp=currscr>=128?1:0;
27318
27319
2/2
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 1980088 times.
1980749 if(index==-1)
27320 {
27321
2/2
✓ Branch 0 taken 465415 times.
✓ Branch 1 taken 1980088 times.
2445503 for(auto ind = items.Count()-1; ind >= 0; --ind)
27322 {
27323 465415 item* itm = (item*)items.spr(ind);
27324
1/2
✓ Branch 0 taken 465415 times.
✗ Branch 1 not taken.
465415 if(itm->get_forcegrab())
27325 {
27326 checkitems(ind);
27327 }
27328 465415 }
27329
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 1970739 times.
1980088 if(diagonalMovement)
27330 {
27331 9349 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
27332 9349 }
27333 1970739 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
27334 1980088 }
27335
27336
2/2
✓ Branch 0 taken 17563 times.
✓ Branch 1 taken 1963186 times.
1980749 if(index==-1)
27337 1963186 return;
27338
27339 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
27340 // return;
27341 17563 item* ptr = (item*)items.spr(index);
27342 17563 int32_t pickup = ptr->pickup;
27343 17563 int8_t exstate = ptr->pickupexstate;
27344 17563 int32_t PriceIndex = ptr->PriceIndex;
27345 17563 int32_t id2 = ptr->id;
27346 17563 int32_t holdid = ptr->id;
27347 17563 int32_t pstr = ptr->pstring;
27348 17563 int32_t pstr_flags = ptr->pickup_string_flags;
27349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17563 times.
17563 if(ptr->fallclk > 0) return; //Don't pick up a falling item
27350
27351
1/2
✓ Branch 0 taken 17563 times.
✗ Branch 1 not taken.
17563 if(itemsbuf[id2].family == itype_progressive_itm)
27352 {
27353 int32_t newid = get_progressive_item(itemsbuf[id2]);
27354 if(newid > -1)
27355 {
27356 id2 = newid;
27357 holdid = newid;
27358 pstr = itemsbuf[newid].pstring;
27359 pstr_flags = itemsbuf[newid].pickup_string_flags;
27360 }
27361 }
27362
27363
2/2
✓ Branch 0 taken 17411 times.
✓ Branch 1 taken 152 times.
17563 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
27364
27365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17563 times.
17563 if(bottledummy) //Dummy bullshit!
27366 {
27367 if(!game->canFillBottle())
27368 return;
27369 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27370 {
27371 if(!current_item_power(itype_wallet))
27372 {
27373 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27374 int32_t tmpprice = -abs(prices[PriceIndex]);
27375 //game->change_drupy(-abs(prices[priceindex]));
27376 int32_t total = game->get_drupy()-tmpprice;
27377 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27378 game->set_drupy(game->get_drupy()-total);
27379 }
27380 else //infinite wallet
27381 {
27382 game->change_drupy(0);
27383 }
27384 }
27385 boughtsomething=true;
27386 //make the other shop items untouchable after
27387 //you buy something
27388 int32_t count = 0;
27389
27390 for(int32_t i=0; i<3; i++)
27391 {
27392 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
27393 {
27394 ++count;
27395 }
27396 }
27397
27398 for(int32_t i=0; i<items.Count(); i++)
27399 {
27400 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27401 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27402 }
27403
27404 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
27405 id2 = find_bottle_for_slot(slot);
27406 ptr->id = id2;
27407 pstr = 0;
27408 pickup |= ipHOLDUP;
27409 }
27410 else
27411 {
27412 17563 std::vector<int32_t> &ev = FFCore.eventData;
27413 17563 ev.clear();
27414 17563 ev.push_back(id2*10000);
27415 17563 ev.push_back(pickup*10000);
27416 17563 ev.push_back(pstr*10000);
27417 17563 ev.push_back(pstr_flags*10000);
27418 17563 ev.push_back(0);
27419 17563 ev.push_back(ptr->getUID());
27420 17563 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
27421 17563 ev.push_back(0);
27422
27423 17563 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
27424 17563 bool nullify = ev[4] != 0;
27425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17563 times.
17563 if(nullify) return;
27426 17563 id2 = ev[0]/10000;
27427 17563 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
27428 17563 pstr = ev[2] / 10000;
27429 17563 pstr_flags = ev[3] / 10000;
27430
27431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17563 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17563 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
27432 return; //No picking these up unless you have a bottle to fill!
27433
27434
5/6
✓ Branch 0 taken 16828 times.
✓ Branch 1 taken 735 times.
✓ Branch 2 taken 14638 times.
✓ Branch 3 taken 2190 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14638 times.
17563 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
27435
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 40 times.
14638 if(ptr->id!=iFairyMoving)
27436 // wait for it to stop flashing, doesn't check for other items yet
27437 14598 return;
27438
27439
2/2
✓ Branch 0 taken 2951 times.
✓ Branch 1 taken 14 times.
2965 if(pickup&ipENEMY) // item was being carried by enemy
27440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
28 if(more_carried_items()<=1) // 1 includes this own item.
27441 14 hasitem &= ~2;
27442
27443
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 2768 times.
2965 if(pickup&ipDUMMY) // dummy item (usually a rupee)
27444 {
27445
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 20 times.
197 if(pickup&ipMONEY)
27446 20 dospecialmoney(index);
27447
27448 197 return;
27449 }
27450
27451
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2768 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
27452 return;
27453
27454 2768 int32_t nextitem = -1;
27455 2768 do
27456 {
27457 2768 nextitem = -1;
27458
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2760 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 5 times.
2768 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
27459 // Item upgrade routine.
27460 {
27461
27462
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 5 times.
1285 for(int32_t i=0; i<MAXITEMS; i++)
27463 {
27464 // Find the item which is as close to this item's fam_type as possible.
27465
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1270 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
1280 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
27466
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27467 {
27468 5 nextitem = i;
27469 5 }
27470 1280 }
27471
27472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(nextitem>-1)
27473 {
27474 5 id2 = nextitem;
27475
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
27476 {
27477 pstr = itemsbuf[id2].pstring;
27478 pstr_flags = itemsbuf[id2].pickup_string_flags;
27479 }
27480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27481 5 break; //no looping
27482 }
27483 }
27484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2763 times.
2763 } while(nextitem > -1);
27485
27486
2/2
✓ Branch 0 taken 2616 times.
✓ Branch 1 taken 152 times.
2768 if(pickup&ipCHECK) // check restrictions
27487
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 104 times.
152 switch(tmpscr[tmp].room)
27488 {
27489 case rSP_ITEM: // special item
27490
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
26 if(!canget(id2)) // These ones always need the Hearts Required check
27491 1 return;
27492
27493 25 break;
27494
27495 case rP_SHOP: // potion shop
27496
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 11 times.
104 if(msg_active)
27497 93 return;
27498 [[fallthrough]];
27499 case rSHOP: // shop
27500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27501 {
27502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!current_item_power(itype_wallet))
27503 {
27504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27505 33 int32_t tmpprice = -abs(prices[PriceIndex]);
27506 //game->change_drupy(-abs(prices[priceindex]));
27507 33 int32_t total = game->get_drupy()-tmpprice;
27508 33 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27509 33 game->set_drupy(game->get_drupy()-total);
27510 33 }
27511 else //infinite wallet
27512 {
27513 game->change_drupy(0);
27514 }
27515 33 }
27516 33 boughtsomething=true;
27517 //make the other shop items untouchable after
27518 //you buy something
27519 33 int32_t count = 0;
27520
27521
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 33 times.
132 for(int32_t i=0; i<3; i++)
27522 {
27523
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 90 times.
99 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
27524 {
27525 90 ++count;
27526 90 }
27527 99 }
27528
27529
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 33 times.
156 for(int32_t i=0; i<items.Count(); i++)
27530 {
27531
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 57 times.
123 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27532 57 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27533 123 }
27534
27535 33 break;
27536 58 }
27537
27538
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 2386 times.
2674 if(pickup&ipONETIME) // set mITEM for one-time-only items
27539 {
27540 288 setmapflag(mITEM);
27541
27542 //Okay so having old source files is a godsend. You wanna know why?
27543 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
27544 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
27545 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
27546 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
27547 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
27548
27549 /*
27550 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
27551 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
27552
27553 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
27554 // What is etc?! We need to check for every valid state here. ~Gleeok
27555 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
27556 {
27557 // Most older quests need one-time-pickups to not remove special items, etc.
27558 if(tmpscr->room==rGRUMBLE)
27559 {
27560 setmapflag(mSPECIALITEM);
27561 }
27562 }
27563 */
27564 288 }
27565
2/2
✓ Branch 0 taken 2265 times.
✓ Branch 1 taken 121 times.
2386 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
27566
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 11 times.
121 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27567
27568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2674 if(exstate > -1 && exstate < 32)
27569 {
27570 setxmapflag(1<<exstate);
27571 }
27572
27573
1/2
✓ Branch 0 taken 2674 times.
✗ Branch 1 not taken.
2674 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
27574 {
27575 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
27576 hidden_entrance(0, true, false, -5);
27577 }
27578
27579 2674 collectitem_script(id2);
27580 2674 getitem(id2, false, true);
27581 }
27582
27583
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 2462 times.
2674 if(pickup&ipHOLDUP)
27584 {
27585 212 attackclk=0;
27586 212 reset_swordcharge();
27587
27588
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 210 times.
212 if(action!=swimming && !IsSideSwim())
27589 210 reset_hookshot();
27590
27591
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 68 times.
212 if(msg_onscreen)
27592 {
27593 68 dismissmsg();
27594 68 }
27595
27596 212 clear_bitmap(pricesdisplaybuf);
27597
27598
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
212 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
27599 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
27600 {
27601 212 fadeclk=66;
27602 212 }
27603
27604
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
212 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
27605 {
27606 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
27607
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 208 times.
210 if(action==swimming)
27608 {
27609 2 action=waterhold1; FFCore.setHeroAction(waterhold1);
27610 2 }
27611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 else if(IsSideSwim())
27612 {
27613 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
27614 }
27615 else
27616 {
27617 208 action=landhold1; FFCore.setHeroAction(landhold1);
27618 }
27619
27620
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 74 times.
210 if(ptr->twohand)
27621 {
27622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(action==waterhold1)
27623 {
27624 action=waterhold2; FFCore.setHeroAction(waterhold2);
27625 }
27626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 else if(action==sidewaterhold1)
27627 {
27628 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
27629 }
27630 else
27631 {
27632 74 action=landhold2; FFCore.setHeroAction(landhold2);
27633 }
27634 74 }
27635
27636 210 holdclk=130;
27637
27638 //restart music
27639
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 30 times.
210 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
27640 30 music_stop();
27641
27642 210 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
27643 210 freeze_guys=true;
27644 //show the info string
27645
27646
27647 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
27648
27649 210 int32_t shop_pstr = 0;
27650
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 43 times.
210 if (PriceIndex > -1)
27651 {
27652
2/3
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
43 switch(tmpscr[tmp].room)
27653 {
27654 case rSHOP:
27655 22 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
27656 22 break;
27657 case rBOTTLESHOP:
27658 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
27659 break;
27660 }
27661 43 }
27662
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 210 times.
210 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27663 {
27664 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
27665 {
27666 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27667 }
27668 else pstr = 0;
27669 if(shop_pstr)
27670 {
27671 donewmsg(shop_pstr);
27672 enqueued_str = pstr;
27673 }
27674 else if(pstr)
27675 {
27676 donewmsg(pstr);
27677 }
27678 }
27679
27680 210 }
27681
27682
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
212 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
27683 {
27684 182 sfx(tmpscr[0].holdupsfx);
27685 182 }
27686
27687 212 ptr->set_forcegrab(false);
27688 212 items.del(index);
27689
27690
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 212 times.
245 for(int32_t i=0; i<Lwpns.Count(); i++)
27691 {
27692 33 weapon *w = (weapon*)Lwpns.spr(i);
27693
27694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(w->dragging==index)
27695 {
27696 w->dragging=-1;
27697 }
27698
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 else if(w->dragging>index)
27699 {
27700 w->dragging-=1;
27701 }
27702 33 }
27703
27704 // clear up shop stuff
27705
4/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 41 times.
212 if((isdungeon()==0)&&(index!=0))
27706 {
27707
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 32 times.
41 if(boughtsomething)
27708 {
27709 32 fadeclk=66;
27710
27711
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
27712 {
27713 32 items.del(0);
27714
27715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 for(int32_t i=0; i<Lwpns.Count(); i++)
27716 {
27717 weapon *w = (weapon*)Lwpns.spr(i);
27718
27719 if(w->dragging==0)
27720 {
27721 w->dragging=-1;
27722 }
27723 else if(w->dragging>0)
27724 {
27725 w->dragging-=1;
27726 }
27727 }
27728 32 }
27729 32 }
27730
27731
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(msg_onscreen)
27732 {
27733 dismissmsg();
27734 }
27735
27736 41 clear_bitmap(pricesdisplaybuf);
27737 41 set_clip_state(pricesdisplaybuf, 1);
27738 41 }
27739
27740 // items.del(index);
27741 212 }
27742 else
27743 {
27744 2462 ptr->set_forcegrab(false);
27745 2462 items.del(index);
27746
27747
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 2462 times.
4226 for(int32_t i=0; i<Lwpns.Count(); i++)
27748 {
27749 1764 weapon *w = (weapon*)Lwpns.spr(i);
27750
27751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1764 times.
1764 if(w->dragging==index)
27752 {
27753 w->dragging=-1;
27754 }
27755
1/2
✓ Branch 0 taken 1764 times.
✗ Branch 1 not taken.
1764 else if(w->dragging>index)
27756 {
27757 w->dragging-=1;
27758 }
27759 1764 }
27760
27761
2/2
✓ Branch 0 taken 2461 times.
✓ Branch 1 taken 1 times.
2462 if(msg_onscreen)
27762 {
27763 1 dismissmsg();
27764 1 }
27765
27766 //general item pickup message
27767 //show the info string
27768 //non-held
27769 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
27770
3/6
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 2413 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2462 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
27771
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2462 times.
2462 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27772 {
27773 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
27774 {
27775 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27776 }
27777 else pstr = 0;
27778 if(shop_pstr)
27779 {
27780 donewmsg(shop_pstr);
27781 enqueued_str = pstr;
27782 }
27783 else if(pstr)
27784 {
27785 donewmsg(pstr);
27786 }
27787 }
27788
27789
27790 2462 clear_bitmap(pricesdisplaybuf);
27791 2462 set_clip_state(pricesdisplaybuf, 1);
27792 }
27793
27794
2/2
✓ Branch 0 taken 2642 times.
✓ Branch 1 taken 32 times.
2674 if(itemsbuf[id2].family==itype_triforcepiece)
27795 {
27796
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2 times.
32 if(itemsbuf[id2].misc2>0) //Small TF Piece
27797 {
27798 30 getTriforce(id2);
27799 30 }
27800 else
27801 {
27802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ptr->linked_parent == eeGANON) game->lvlitems[dlevel]|=liBOSS;
27803 2 getBigTri(id2);
27804 }
27805 32 }
27806 1980749 }
27807
27808 83 void HeroClass::StartRefill(int32_t refillWhat)
27809 {
27810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(!refilling)
27811 {
27812 83 refillclk=21;
27813 83 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27814 83 sfx(WAV_REFILL,128,true);
27815 83 refilling=refillWhat;
27816
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(FFCore.quest_format[vZelda] < 0x255)
27817 {
27818 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
27819 //I attempted to change this check to a quest rule, but here's the issue: this affects
27820 //triforces and potions as well, not just fairy flags. This means that having a compat rule
27821 //would result in a rule that is checked by default for every tileset or quest made before
27822 //2.55, one in a place most people won't check. That means that if they were to go to use
27823 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
27824 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
27825 //"go through the compat rules and turn them all off", so this remains a version check instead
27826 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
27827 83 Start250Refill(refillWhat);
27828 83 }
27829 else //use 2.55+ behavior
27830 {
27831 if(refill_why>=0) // Item index
27832 {
27833 if(itemsbuf[refill_why].family==itype_potion)
27834 {
27835 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27836 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27837 }
27838 else if(itemsbuf[refill_why].family==itype_triforcepiece)
27839 {
27840 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27841 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27842 }
27843 }
27844 else if(refill_why==REFILL_FAIRY)
27845 {
27846 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
27847 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
27848 }
27849 }
27850 83 }
27851 83 }
27852
27853 83 void HeroClass::Start250Refill(int32_t refillWhat)
27854 {
27855
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!refilling)
27856 {
27857 refillclk=21;
27858 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27859 sfx(WAV_REFILL,128,true);
27860 refilling=refillWhat;
27861
27862 if(refill_why>=0) // Item index
27863 {
27864 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
27865 {
27866 swordclk=0;
27867 verifyAWpn();
27868 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27869 }
27870
27871 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
27872 {
27873 swordclk=0;
27874 verifyAWpn();
27875 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27876 }
27877 }
27878 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
27879 {
27880 swordclk=0;
27881 verifyAWpn();
27882 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27883 }
27884 }
27885 83 }
27886
27887 54519 bool HeroClass::refill()
27888 {
27889
4/4
✓ Branch 0 taken 10741 times.
✓ Branch 1 taken 43778 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 10483 times.
54519 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
27890 {
27891 44036 return false;
27892 }
27893
27894 10483 ++refillclk;
27895 10483 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
27896 10483 int32_t refill_heart_stop=game->get_maxlife();
27897 10483 int32_t refill_magic_stop=game->get_maxmagic();
27898
27899
4/4
✓ Branch 0 taken 5443 times.
✓ Branch 1 taken 5040 times.
✓ Branch 2 taken 2072 times.
✓ Branch 3 taken 3371 times.
10483 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
27900 {
27901
2/6
✓ Branch 0 taken 3371 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3371 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3371 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
27902
2/6
✓ Branch 0 taken 3371 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3371 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3371 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
27903 3371 }
27904
27905
2/2
✓ Branch 0 taken 9820 times.
✓ Branch 1 taken 663 times.
10483 if(refillclk%speed == 0)
27906 {
27907 // game->life&=0xFFC;
27908
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 307 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 356 times.
663 switch(refill_what)
27909 {
27910 case REFILL_LIFE:
27911
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 298 times.
307 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
27912
27913
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 267 times.
307 if(game->get_life()>=refill_heart_stop)
27914 {
27915 40 game->set_life(refill_heart_stop);
27916 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
27917
2/2
✓ Branch 0 taken 10240 times.
✓ Branch 1 taken 40 times.
10280 for ( int32_t q = 0; q < WAV_COUNT; q++ )
27918 {
27919
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10200 times.
10240 if ( q == (int32_t)tmpscr->oceansfx ) continue;
27920
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10199 times.
10200 if ( q == (int32_t)tmpscr->bosssfx ) continue;
27921 10199 stop_sfx(q);
27922 10199 }
27923 40 sfx(QMisc.miscsfx[sfxREFILL]);
27924 40 refilling=REFILL_NONE;
27925 40 return false;
27926 }
27927
27928 267 break;
27929
27930 case REFILL_MAGIC:
27931 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
27932
27933 if(game->get_magic()>=refill_magic_stop)
27934 {
27935 game->set_magic(refill_magic_stop);
27936 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
27937 for ( int32_t q = 0; q < WAV_COUNT; q++ )
27938 {
27939 if ( q == (int32_t)tmpscr->oceansfx ) continue;
27940 if ( q == (int32_t)tmpscr->bosssfx ) continue;
27941 stop_sfx(q);
27942 }
27943 sfx(QMisc.miscsfx[sfxREFILL]);
27944 refilling=REFILL_NONE;
27945 return false;
27946 }
27947
27948 break;
27949
27950 case REFILL_ALL:
27951
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 330 times.
356 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
27952
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
27953
27954
3/4
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
356 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
27955 {
27956 43 game->set_life(refill_heart_stop);
27957 43 game->set_magic(refill_magic_stop);
27958 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
27959
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for ( int32_t q = 0; q < WAV_COUNT; q++ )
27960 {
27961
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 10965 times.
11008 if ( q == (int32_t)tmpscr->oceansfx ) continue;
27962
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 10949 times.
10965 if ( q == (int32_t)tmpscr->bosssfx ) continue;
27963 10949 stop_sfx(q);
27964 10949 }
27965 43 sfx(QMisc.miscsfx[sfxREFILL]);
27966 43 refilling=REFILL_NONE;
27967 43 return false;
27968 }
27969
27970 313 break;
27971 }
27972 580 }
27973
27974 10400 return true;
27975 54519 }
27976
27977 30 void HeroClass::getTriforce(int32_t id2)
27978 {
27979
27980 PALETTE flash_pal;
27981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
27982
27983
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i=0; i<256; i++)
27984 {
27985
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 5888 times.
7680 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
27986 7680 }
27987
27988
27989
27990 //get rid off all sprites but Hero
27991 30 guys.clear();
27992 30 items.clear();
27993 30 Ewpns.clear();
27994 30 Lwpns.clear();
27995 30 Sitems.clear();
27996 30 chainlinks.clear();
27997
27998 //decorations.clear();
27999
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 17 times.
30 if(!COOLSCROLL)
28000 {
28001 17 show_subscreen_items=false;
28002 17 }
28003
28004 30 sfx(itemsbuf[id2].playsound);
28005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
28006
28007 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
28008
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
28009 {
28010 uint8_t playwav = itemsbuf[id2].misc3;
28011 //zprint2("playwav is: %d\n", playwav);
28012 sfx(playwav);
28013
28014 }
28015
28016 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
28017 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
28018 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
28019 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
28020 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
28021 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
28022 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
28023
28024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
28025 {
28026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(itemsbuf[id2].misc1)
28027 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
28028 else
28029 30 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
28030 30 }
28031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28032 {
28033 30 game->lvlitems[dlevel]|=liTRIFORCE;
28034 30 }
28035
28036 30 int32_t f=0;
28037 30 int32_t x2=0;
28038 30 int32_t curtain_x=0;
28039 30 int32_t c=0;
28040 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
28041 {
28042 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
28043 {
28044 //clear the item script stack for a new script
28045 ri = &(itemCollectScriptData[id2]);
28046 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
28047 ri->Clear();
28048 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
28049 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
28050 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
28051 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
28052 {
28053 item_collect_doscript[id2] = 1;
28054 itemscriptInitialised[id2] = 0;
28055 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
28056 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28057 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
28058 }
28059 else if (!id2 && !item_collect_doscript[id2]) //item 0
28060 {
28061 item_collect_doscript[id2] = 1;
28062 itemscriptInitialised[id2] = 0;
28063 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
28064 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28065 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
28066 }
28067 }
28068 }
28069 */
28070 30 do
28071 {
28072
28073
28074
1/2
✓ Branch 0 taken 16420 times.
✗ Branch 1 not taken.
16420 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
28075 {
28076 if ( itemsbuf[id2].script )
28077 {
28078 if ( !item_doscript[id2] )
28079 {
28080 ri = &(itemScriptData[id2]);
28081 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
28082 ri->Clear();
28083 item_doscript[id2] = 1;
28084 itemscriptInitialised[id2] = 0;
28085 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
28086 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
28087 }
28088 else
28089 {
28090 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
28091 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
28092 }
28093 }
28094 }
28095 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
28096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16420 times.
16420 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
28097 {
28098 return;
28099 }
28100
2/2
✓ Branch 0 taken 16390 times.
✓ Branch 1 taken 30 times.
16420 if(f==40)
28101 {
28102 30 actiontype oldaction = action;
28103 30 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
28104 30 action=oldaction; // have to reset this flag
28105 30 FFCore.setHeroAction(oldaction);
28106 30 }
28107
28108
28109
4/4
✓ Branch 0 taken 15220 times.
✓ Branch 1 taken 1200 times.
✓ Branch 2 taken 13780 times.
✓ Branch 3 taken 1440 times.
16420 if(f>=40 && f<88)
28110 {
28111
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 1104 times.
1440 if(get_bit(quest_rules,qr_FADE))
28112 {
28113 //int32_t flashbit = ;
28114
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 84 times.
336 if((f&(((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)) ? 6 : 3))==0)
28115 {
28116 84 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
28117 84 refreshpal=true;
28118 84 }
28119
28120
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 84 times.
336 if((f&3)==2)
28121 {
28122 84 loadpalset(0,0);
28123 84 loadpalset(1,1);
28124 84 loadpalset(5,5);
28125
28126
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28127 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
28128 84 }
28129 336 }
28130 else
28131 {
28132
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 138 times.
1104 if((f&((get_bit(quest_rules,qr_EPILEPSY)) ? 10 : 7))==0)
28133 {
28134
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 138 times.
552 for(int32_t cs2=2; cs2<5; cs2++)
28135 {
28136
2/2
✓ Branch 0 taken 6210 times.
✓ Branch 1 taken 414 times.
6624 for(int32_t i=1; i<16; i++)
28137 {
28138 6210 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
28139 6210 }
28140 414 }
28141
28142 138 refreshpal=true;
28143 138 }
28144
28145
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 138 times.
1104 if((f&7)==4)
28146 {
28147
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28148 else loadlvlpal(0xB);
28149
28150 138 loadpalset(5,5);
28151 138 }
28152 }
28153 1440 }
28154
28155
28156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16420 times.
16420 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28157 {
28158
2/2
✓ Branch 0 taken 16390 times.
✓ Branch 1 taken 30 times.
16420 if(f==refill_frame)
28159 {
28160 30 refill_what=REFILL_ALL;
28161 30 refill_why=id2;
28162 30 StartRefill(REFILL_ALL);
28163 30 refill();
28164 30 }
28165
28166
2/2
✓ Branch 0 taken 14370 times.
✓ Branch 1 taken 2050 times.
16420 if(f==(refill_frame+1))
28167 {
28168
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2020 times.
2050 if(refill())
28169 {
28170 2020 --f;
28171 2020 }
28172 2050 }
28173 16420 }
28174
28175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16420 times.
16420 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
28176 {
28177
4/4
✓ Branch 0 taken 8160 times.
✓ Branch 1 taken 8260 times.
✓ Branch 2 taken 5760 times.
✓ Branch 3 taken 2400 times.
16420 if(f>=208 && f<288)
28178 {
28179 2400 ++x2;
28180
28181
3/3
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 480 times.
2400 switch(++c)
28182 {
28183 case 5:
28184 480 c=0;
28185 [[fallthrough]];
28186 case 0:
28187 case 2:
28188 case 3:
28189 1440 ++x2;
28190 1440 break;
28191 }
28192 2400 }
28193
28194 16420 do_dcounters();
28195
28196
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 10660 times.
16420 if(f<288)
28197 {
28198 10660 curtain_x=x2&0xF8;
28199 10660 draw_screen_clip_rect_x1=curtain_x;
28200 10660 draw_screen_clip_rect_x2=255-curtain_x;
28201 10660 draw_screen_clip_rect_y1=0;
28202 10660 draw_screen_clip_rect_y2=223;
28203 //draw_screen(tmpscr);
28204 10660 }
28205 16420 }
28206
28207 16420 draw_screen(tmpscr);
28208 //this causes bugs
28209 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
28210 //so this is not necessary -DD
28211 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
28212
28213 //Run Triforce Script
28214 16420 advanceframe(true);
28215 16420 ++f;
28216
2/2
✓ Branch 0 taken 16390 times.
✓ Branch 1 taken 30 times.
32840 }
28217 while
28218 (
28219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16420 times.
16420 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
28220
4/6
✓ Branch 0 taken 2190 times.
✓ Branch 1 taken 14230 times.
✓ Branch 2 taken 2190 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2190 times.
16420 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
28221
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2045 times.
✓ Branch 7 taken 145 times.
4380 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
28222 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
28223 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
28224 // value doesn't matter.
28225
2/4
✓ Branch 0 taken 2045 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2190 times.
2190 || (replay_is_active() && f < 480) )
28226 ); // 800 may not be just right, but it works
28227
28228 30 action=none; FFCore.setHeroAction(none);
28229 30 holdclk=0;
28230 30 draw_screen_clip_rect_x1=0;
28231 30 draw_screen_clip_rect_x2=255;
28232 30 draw_screen_clip_rect_y1=0;
28233 30 draw_screen_clip_rect_y2=223;
28234 30 show_subscreen_items=true;
28235
28236 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
28237 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
28238
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
30 if(itemsbuf[id2].flags & ITEM_FLAG1 && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
28239 {
28240 31 sdir=dir;
28241 31 dowarp(1,0); //side warp
28242 31 }
28243 else
28244 {
28245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
28246 }
28247 30 }
28248
28249 void red_shift()
28250 {
28251 int32_t tnum=176;
28252
28253 // set up the new palette
28254 for(int32_t i=CSET(2); i < CSET(4); i++)
28255 {
28256 int32_t r = (i-CSET(2)) << 1;
28257 RAMpal[i+tnum].r = r;
28258 RAMpal[i+tnum].g = r >> 3;
28259 RAMpal[i+tnum].b = r >> 4;
28260 }
28261
28262 // color scale the game screen
28263 for(int32_t y=0; y<168; y++)
28264 {
28265 for(int32_t x=0; x<256; x++)
28266 {
28267 int32_t c = framebuf->line[y+playing_field_offset][x];
28268 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28269 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
28270 }
28271 }
28272
28273 refreshpal = true;
28274 }
28275
28276
28277
28278 void setup_red_screen_old()
28279 {
28280 clear_bitmap(framebuf);
28281 rectfill(scrollbuf, 0, 0, 255, 167, 0);
28282
28283 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
28284
28285 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
28286
28287 putscr(scrollbuf, 0, 0, tmpscr);
28288 putscrdoors(scrollbuf,0,0,tmpscr);
28289 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28290 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
28291
28292 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
28293
28294 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
28295 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
28296 {
28297 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
28298 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
28299 }
28300
28301 if(!(msg_bg_display_buf->clip))
28302 {
28303 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28304 }
28305
28306 if(!(msg_portrait_display_buf->clip))
28307 {
28308 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28309 }
28310
28311 if(!(msg_txt_display_buf->clip))
28312 {
28313 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28314 }
28315
28316 if(!(pricesdisplaybuf->clip))
28317 {
28318 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
28319 }
28320
28321 //red shift
28322 // color scale the game screen
28323 for(int32_t y=0; y<168; y++)
28324 {
28325 for(int32_t x=0; x<256; x++)
28326 {
28327 int32_t c = framebuf->line[y+playing_field_offset][x];
28328 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28329 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
28330 }
28331 }
28332
28333 // Hero->draw(framebuf);
28334 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
28335
28336 clear_bitmap(framebuf);
28337
28338 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
28339 && tmpscr->layermap[3]==0
28340 && tmpscr->layermap[4]==0
28341 && tmpscr->layermap[5]==0
28342 && !overheadcombos(tmpscr)))
28343 {
28344 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
28345
28346 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
28347 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
28348 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
28349 {
28350 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
28351 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
28352 }
28353 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
28354 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
28355
28356 //do an AND masked blit for messages on top of layers
28357 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
28358 {
28359 BITMAP* subbmp = create_bitmap_ex(8,256,168);
28360 clear_bitmap(subbmp);
28361 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
28362 {
28363 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
28364 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
28365 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
28366 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
28367 }
28368 for(int32_t y=0; y<168; y++)
28369 {
28370 for(int32_t x=0; x<256; x++)
28371 {
28372 int32_t c1 = framebuf->line[y+playing_field_offset][x];
28373 int32_t c2 = subbmp->line[y][x];
28374 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
28375
28376 if(c1 && c3)
28377 {
28378 framebuf->line[y+playing_field_offset][x] = c3;
28379 }
28380 else if(c1 && c2)
28381 {
28382 framebuf->line[y+playing_field_offset][x] = c2;
28383 }
28384 }
28385 }
28386 destroy_bitmap(subbmp);
28387 }
28388
28389 //red shift
28390 // color scale the game screen
28391 for(int32_t y=0; y<168; y++)
28392 {
28393 for(int32_t x=0; x<256; x++)
28394 {
28395 int32_t c = framebuf->line[y+playing_field_offset][x];
28396 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28397 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
28398 }
28399 }
28400 }
28401
28402 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
28403
28404 // set up the new palette
28405 for(int32_t i=CSET(2); i < CSET(4); i++)
28406 {
28407 int32_t r = (i-CSET(2)) << 1;
28408 RAMpal[i].r = r;
28409 RAMpal[i].g = r >> 3;
28410 RAMpal[i].b = r >> 4;
28411 }
28412
28413 refreshpal = true;
28414 }
28415
28416
28417
28418 35 void slide_in_color(int32_t color)
28419 {
28420
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 35 times.
210 for(int32_t i=1; i<16; i+=3)
28421 {
28422 175 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
28423 175 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
28424 175 RAMpal[CSET(2)+i] = NESpal(color);
28425 175 }
28426
28427 35 refreshpal=true;
28428 35 }
28429
28430
28431 7 void HeroClass::heroDeathAnimation()
28432 {
28433 7 int32_t f=0;
28434 7 int32_t deathclk=0,deathfrm=0;
28435
28436 7 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
28437
28438 7 kill_sfx(); //call before the onDeath script.
28439
28440 //do
28441 //{
28442
28443 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28444 // FFCore.Waitframe();
28445 //}while(player_doscript);
28446 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28447 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
28448
28449 //Playing=false;
28450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!debug_enabled)
28451 {
28452 7 Paused=false;
28453 7 }
28454
28455 /*
28456 game->set_deaths(zc_min(game->get_deaths()+1,999));
28457 dir=down;
28458 music_stop();
28459
28460 attackclk=hclk=superman=0;
28461 scriptcoldet = 1;
28462
28463 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28464
28465
28466
28467 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28468 quakeclk=wavy=0;
28469
28470 //in original Z1, Hero marker vanishes at death.
28471 //code in subscr.cpp, put_passive_subscr checks the following value.
28472 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28473 //Also, subscreen is static after death in Z1.
28474 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28475 QMisc.colors.hero_dot = 255;
28476 //doesn't work
28477 //scrollbuf is tampered with by draw_screen()
28478 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28479 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28480 clear_bitmap(subscrbmp);
28481 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
28482 QMisc.colors.hero_dot = tmp_hero_dot;
28483 */
28484 7 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28485 7 clear_bitmap(subscrbmp);
28486 //get rid off all sprites but Hero
28487 7 guys.clear();
28488 7 items.clear();
28489 7 Ewpns.clear();
28490 7 Lwpns.clear();
28491 7 Sitems.clear();
28492 7 chainlinks.clear();
28493 7 decorations.clear();
28494 7 Playing = false;
28495
28496
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
28497 7 dir=down;
28498 7 music_stop();
28499
28500 7 attackclk=hclk=superman=0;
28501 7 scriptcoldet = 1;
28502
28503
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 7 times.
231 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28504
28505
28506
28507 7 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28508 7 quakeclk=wavy=0;
28509
28510 //in original Z1, Hero marker vanishes at death.
28511 //code in subscr.cpp, put_passive_subscr checks the following value.
28512 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28513 //Also, subscreen is static after death in Z1.
28514 7 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28515 7 QMisc.colors.hero_dot = 255;
28516 //doesn't work
28517 //scrollbuf is tampered with by draw_screen()
28518 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28519
28520 7 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
28521 //Don't forget passive subscreen scripts!
28522
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
28523 {
28524 script_drawing_commands.Clear(); //We only want draws from this script
28525 if(DMaps[currdmap].passive_sub_script != 0)
28526 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28527 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
28528 {
28529 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28530 passive_subscreen_waitdraw = false;
28531 }
28532 BITMAP* tmp = framebuf;
28533 framebuf = subscrbmp; //Hack; force draws to subscrbmp
28534 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
28535 framebuf = tmp;
28536 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
28537 }
28538 7 QMisc.colors.hero_dot = tmp_hero_dot;
28539 7 bool clearedit = false;
28540 7 do
28541 {
28542 //if ( player_doscript )
28543 //{
28544 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_WIN, SCRIPT_PLAYER_WIN);
28545 //if ( f ) --f;
28546 // load_control_state(); //goto adv;
28547 //}
28548 //else
28549 //{
28550 // if ( !clearedit )
28551 // {
28552
28553
28554 // clearedit = true;
28555
28556 // }
28557 //}
28558 //else Playing = false;
28559
2/2
✓ Branch 0 taken 1778 times.
✓ Branch 1 taken 693 times.
2471 if(f<254)
28560 {
28561
2/2
✓ Branch 0 taken 1547 times.
✓ Branch 1 taken 231 times.
1778 if(f<=32)
28562 {
28563 231 hclk=(32-f);
28564 231 }
28565
28566
4/4
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 434 times.
✓ Branch 2 taken 812 times.
✓ Branch 3 taken 532 times.
1778 if(f>=62 && f<138)
28567 {
28568
5/5
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 28 times.
532 switch((f-62)%20)
28569 {
28570 case 0:
28571 28 dir=right;
28572 28 break;
28573
28574 case 5:
28575 28 dir=up;
28576 28 break;
28577
28578 case 10:
28579 28 dir=left;
28580 28 break;
28581
28582 case 15:
28583 28 dir=down;
28584 28 break;
28585 }
28586
28587 532 herostep();
28588 532 }
28589
28590
4/4
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 1358 times.
✓ Branch 2 taken 322 times.
✓ Branch 3 taken 98 times.
1778 if(f>=194 && f<208)
28591 {
28592
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 7 times.
98 if(f==194)
28593 {
28594 7 action=dying;
28595 7 FFCore.setHeroAction(dying);
28596 7 }
28597
28598 98 extend = 0;
28599 98 cs = wpnsbuf[spr_death].csets&15;
28600 98 tile = wpnsbuf[spr_death].tile;
28601
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
28602 {
28603 tile += deathfrm;
28604 f = 206;
28605 if(++deathclk >= wpnsbuf[spr_death].speed)
28606 {
28607 deathclk=0;
28608 if(++deathfrm >= wpnsbuf[spr_death].frames)
28609 {
28610 f = 208;
28611 deathfrm = 0;
28612 }
28613 }
28614 }
28615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 else if(BSZ)
28616 {
28617 tile += (f-194)/3;
28618 }
28619
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 28 times.
98 else if(f>=204)
28620 {
28621 28 ++tile;
28622 28 }
28623 98 }
28624
28625
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==208)
28626 {
28627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if ( dontdraw < 2 ) { dontdraw = 1; }
28628 7 }
28629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1778 times.
1778 if(get_bit(quest_rules,qr_FADE))
28630 {
28631 if(f < 170)
28632 {
28633 if(f<60)
28634 {
28635 draw_screen(tmpscr);
28636 //reuse our static subscreen
28637 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28638 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28639 }
28640
28641 if(f==60)
28642 {
28643 red_shift();
28644 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28645 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28646 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28647
28648 for(int32_t q=0; q<PAL_SIZE; q++)
28649 {
28650 trans_table2.data[0][q] = q;
28651 trans_table2.data[q][q] = q;
28652 }
28653 }
28654
28655 if(f>=60 && f<=169)
28656 {
28657 draw_screen(tmpscr);
28658 //reuse our static subscreen
28659 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28660 red_shift();
28661
28662 }
28663
28664 if(f>=139 && f<=169)//fade from red to black
28665 {
28666 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
28667 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28668 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28669 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28670
28671 for(int32_t q=0; q<PAL_SIZE; q++)
28672 {
28673 trans_table2.data[0][q] = q;
28674 trans_table2.data[q][q] = q;
28675 }
28676
28677 refreshpal=true;
28678 }
28679 }
28680 else //f>=170
28681 {
28682 if(f==170)//make Hero grayish
28683 {
28684 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
28685
28686 for(int32_t i=CSET(6); i < CSET(7); i++)
28687 {
28688 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
28689 RAMpal[i] = _RGB(g,g,g);
28690 }
28691
28692 refreshpal = true;
28693 }
28694
28695 //draw only hero. otherwise black layers might cover him.
28696 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28697 draw(framebuf);
28698 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28699 }
28700 }
28701 else //!qr_FADE
28702 {
28703
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==58)
28704 {
28705
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 7 times.
679 for(int32_t i = 0; i < 96; i++)
28706 672 tmpscr->cset[i] = 3;
28707
28708
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t j=0; j<6; j++)
28709
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
44 if(tmpscr->layermap[j]>0)
28710
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
28711 194 tmpscr2[j].cset[i] = 3;
28712 7 }
28713
28714
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==59)
28715 {
28716
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 7 times.
567 for(int32_t i = 96; i < 176; i++)
28717 560 tmpscr->cset[i] = 3;
28718
28719
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t j=0; j<6; j++)
28720
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
44 if(tmpscr->layermap[j]>0)
28721
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
28722 162 tmpscr2[j].cset[i] = 3;
28723 7 }
28724
28725
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==60)
28726 {
28727
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7 times.
1239 for(int32_t i=0; i<176; i++)
28728 {
28729 1232 tmpscr->cset[i] = 2;
28730 1232 }
28731
28732
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t j=0; j<6; j++)
28733
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
44 if(tmpscr->layermap[j]>0)
28734
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
28735 354 tmpscr2[j].cset[i] = 2;
28736
28737
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7 times.
42 for(int32_t i=1; i<16; i+=3)
28738 {
28739 35 RAMpal[CSET(2)+i] = NESpal(0x17);
28740 35 RAMpal[CSET(2)+i+1] = NESpal(0x16);
28741 35 RAMpal[CSET(2)+i+2] = NESpal(0x26);
28742 35 }
28743
28744 7 refreshpal=true;
28745 7 }
28746
28747
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==139)
28748 7 slide_in_color(0x06);
28749
28750
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==149)
28751 7 slide_in_color(0x07);
28752
28753
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==159)
28754 7 slide_in_color(0x0F);
28755
28756
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==169)
28757 {
28758 7 slide_in_color(0x0F);
28759 7 slide_in_color(0x0F);
28760 7 }
28761
28762
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==170)
28763 {
28764
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7 times.
42 for(int32_t i=1; i<16; i+=3)
28765 {
28766 35 RAMpal[CSET(6)+i] = NESpal(0x10);
28767 35 RAMpal[CSET(6)+i+1] = NESpal(0x30);
28768 35 RAMpal[CSET(6)+i+2] = NESpal(0x00);
28769 35 refreshpal = true;
28770 35 }
28771 7 }
28772
28773
2/2
✓ Branch 0 taken 1183 times.
✓ Branch 1 taken 595 times.
1778 if(f < 169)
28774 {
28775 1183 draw_screen(tmpscr);
28776 //reuse our static subscreen
28777 1183 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28778 1183 }
28779 else
28780 {
28781 //draw only hero. otherwise black layers might cover him.
28782 595 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28783 595 draw(framebuf);
28784 595 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28785 }
28786 }
28787 1778 }
28788
28789
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 21 times.
693 else if(f<350)//draw 'GAME OVER' text
28790 {
28791
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
672 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
28792 {
28793 Quit = qRELOAD;
28794 skipcont = 1;
28795 clear_bitmap(framebuf);
28796 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28797 }
28798
2/4
✓ Branch 0 taken 672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 672 times.
672 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
28799 {
28800 Quit = qCONT;
28801 skipcont = 1;
28802 clear_bitmap(framebuf);
28803 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28804 }
28805 else
28806 {
28807 672 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
28808 672 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28809 672 textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
28810 }
28811 672 }
28812 else
28813 {
28814 21 clear_bitmap(framebuf);
28815 }
28816
28817 //SFX... put them all here
28818
4/4
✓ Branch 0 taken 2450 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 7 times.
2471 switch(f)
28819 {
28820 case 0:
28821 7 sfx(getHurtSFX(),pan(x.getInt()));
28822 7 break;
28823 //Death sound.
28824 case 60:
28825 7 sfx(WAV_SPIRAL);
28826 7 break;
28827 //Message sound.
28828 case 194:
28829 7 sfx(WAV_MSG);
28830 7 break;
28831 }
28832 //adv:
28833 2471 advanceframe(true);
28834 2471 ++f;
28835 //if (!player_doscript ) ++f;
28836
2/2
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 7 times.
4942 }
28837
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2464 times.
2471 while(f<353 && !Quit);
28838
28839 7 destroy_bitmap(subscrbmp);
28840 7 action=none; FFCore.setHeroAction(none);
28841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if ( dontdraw < 2 ) { dontdraw=0; }
28842 7 }
28843
28844
28845 2 void HeroClass::ganon_intro()
28846 {
28847 /*
28848 ************************
28849 * GANON INTRO SEQUENCE *
28850 ************************
28851 -25 DOT updates
28852 -24 HERO in
28853 0 TRIFORCE overhead - code begins at this point (f == 0)
28854 47 GANON in
28855 58 LIGHT step
28856 68 LIGHT step
28857 78 LIGHT step
28858 255 TRIFORCE out
28859 256 TRIFORCE in
28860 270 TRIFORCE out
28861 271 GANON out, HERO face up
28862 */
28863 2 loaded_guys=true;
28864 2 loaditem();
28865
28866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->lvlitems[dlevel]&liBOSS)
28867 {
28868 return;
28869 }
28870
28871 2 dir=down;
28872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !isSideViewHero() )
28873 {
28874 2 fall = 0; //Fix midair glitch on holding triforce. -Z
28875 2 fakefall = 0;
28876 2 z = 0;
28877 2 fakez = 0;
28878 2 }
28879 2 action=landhold2; FFCore.setHeroAction(landhold2);
28880 2 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
28881 //not good, as this only returns the highest level that Hero possesses. -DD
28882 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
28883
28884
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 482 times.
✓ Branch 2 taken 482 times.
✓ Branch 3 taken 2 times.
484 for(int32_t f=0; f<271 && !Quit; f++)
28885 {
28886
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2 times.
482 if(f==47)
28887 {
28888 2 music_stop();
28889 2 stop_sfx(WAV_ROAR);
28890 2 sfx(WAV_GASP);
28891 2 sfx(WAV_GANON);
28892 2 int32_t Id=0;
28893
28894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 for(int32_t i=0; i<eMAXGUYS; i++)
28895 {
28896
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 2 times.
158 if(guysbuf[i].flags2&eneflag_ganon)
28897 {
28898 2 Id=i;
28899 2 break;
28900 }
28901 156 }
28902
28903
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(current_item(itype_ring))
28904 {
28905 1 addenemy(160,96,Id,0);
28906 1 }
28907 else
28908 {
28909 1 addenemy(80,32,Id,0);
28910 }
28911 2 }
28912
28913
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2 times.
482 if(f==48)
28914 {
28915 2 lighting(true,true); // Hmm. -L
28916 2 f += 30;
28917 2 }
28918
28919 //NES Z1, the triforce vanishes for one frame in two cases
28920 //while still showing Hero's two-handed overhead sprite.
28921 //This should be a Quest Rule for NES Accuracy. -Z
28922
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 478 times.
482 if(f==255 || f==270)
28923 {
28924 4 holditem=-1;
28925 4 }
28926
28927
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2 times.
482 if(f==256)
28928 {
28929 2 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
28930 2 }
28931
28932 482 draw_screen(tmpscr);
28933 482 advanceframe(true);
28934
28935
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(rSbtn())
28936 {
28937 conveyclk=3;
28938 int32_t tmp_subscr_clk = frame;
28939 dosubscr(&QMisc);
28940 newscr_clk += frame - tmp_subscr_clk;
28941 }
28942
28943 482 }
28944
28945 2 action=none; FFCore.setHeroAction(none);
28946 2 dir=up;
28947
28948
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
28949 jukebox(MAXMIDIS-1);
28950 else
28951 2 playLevelMusic();
28952
28953 2 currcset=DMaps[currdmap].color;
28954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (get_bit(quest_rules, qr_GANONINTRO) )
28955 {
28956 2 dointro();
28957 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
28958 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
28959 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
28960 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
28961 2 }
28962 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
28963 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
28964 //on a different DMap.
28965 //~ Otherwise, why is it here?! -Z
28966
28967
28968 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
28969 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
28970
28971 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
28972 //Users who use that dmap rule should put ganons room on its own DMap! -Z
28973 2 cont_sfx(WAV_ROAR);
28974 2 }
28975
28976 1 void HeroClass::win_game()
28977 {
28978
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 replay_step_comment("win_game");
28979 1 Playing=Paused=false;
28980 1 action=won; FFCore.setHeroAction(won);
28981 1 Quit=qWON;
28982 1 hclk=0;
28983 1 x = 136;
28984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 y = (isdungeon() && currscr<128) ? 75 : 73;
28985 1 z = fakez = fall = fakefall = spins = 0;
28986 1 dir=left;
28987 1 }
28988
28989 4176 void HeroClass::reset_swordcharge()
28990 {
28991 4176 charging=spins=tapping=0;
28992 4176 }
28993
28994 4637 void HeroClass::reset_hookshot()
28995 {
28996
10/12
✓ Branch 0 taken 4245 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 4241 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4224 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 4221 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 4221 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4221 times.
4637 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
28997 {
28998 4221 action=none; FFCore.setHeroAction(none);
28999 4221 }
29000
29001 4637 hookshot_frozen=false;
29002 4637 hookshot_used=false;
29003 4637 pull_hero=false;
29004 4637 hs_fix=false;
29005 4637 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
29006 4637 switch_hooked = false;
29007
1/2
✓ Branch 0 taken 4637 times.
✗ Branch 1 not taken.
4637 if(switching_object)
29008 switching_object->switch_hooked = false;
29009 4637 switching_object = NULL;
29010 4637 hooked_combopos = -1;
29011 4637 switchhook_cost_item = -1;
29012 4637 hooked_layerbits = 0;
29013
2/2
✓ Branch 0 taken 32459 times.
✓ Branch 1 taken 4637 times.
37096 for(auto q = 0; q < 7; ++q)
29014 32459 hooked_undercombos[q] = -1;
29015 4637 Lwpns.del(Lwpns.idFirst(wHSHandle));
29016 4637 Lwpns.del(Lwpns.idFirst(wHookshot));
29017 4637 chainlinks.clear();
29018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4637 times.
4637 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
29019 4637 hs_switcher = false;
29020
29021
2/2
✓ Branch 0 taken 4461 times.
✓ Branch 1 taken 176 times.
4637 if(index>=0)
29022 {
29023 176 stop_sfx(itemsbuf[index].usesound);
29024 176 }
29025
29026 4637 hs_xdist=0;
29027 4637 hs_ydist=0;
29028 4637 }
29029
29030
29031 507161 bool HeroClass::can_deploy_ladder()
29032 {
29033
2/2
✓ Branch 0 taken 255807 times.
✓ Branch 1 taken 251354 times.
600712 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
29034
4/4
✓ Branch 0 taken 157803 times.
✓ Branch 1 taken 93551 times.
✓ Branch 2 taken 46539 times.
✓ Branch 3 taken 47012 times.
251354 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
29035
8/10
✓ Branch 0 taken 324295 times.
✓ Branch 1 taken 182866 times.
✓ Branch 2 taken 296160 times.
✓ Branch 3 taken 28135 times.
✓ Branch 4 taken 296124 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 296124 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 296124 times.
803285 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
29036
1/2
✓ Branch 0 taken 296124 times.
✗ Branch 1 not taken.
296124 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
29037 }
29038
29039 1933819 void HeroClass::reset_ladder()
29040 {
29041 1933819 ladderx=laddery=0;
29042 1933819 }
29043
29044 bool is_conveyor(int32_t type);
29045 int32_t get_conveyor(int32_t x, int32_t y);
29046
29047 1981852 void HeroClass::check_conveyor()
29048 {
29049 1981852 ++newconveyorclk;
29050
1/2
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
1981852 if (newconveyorclk < 0) newconveyorclk = 0;
29051
29052
13/18
✓ Branch 0 taken 1981852 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1981852 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1981660 times.
✓ Branch 5 taken 192 times.
✓ Branch 6 taken 1981660 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1981660 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1981491 times.
✓ Branch 11 taken 169 times.
✓ Branch 12 taken 1981491 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1981371 times.
✓ Branch 15 taken 120 times.
✓ Branch 16 taken 1981371 times.
✓ Branch 17 taken 120 times.
1981852 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
29053 {
29054 481 is_conveyor_stunned = 0;
29055 481 return;
29056 }
29057
29058 1981371 WalkflagInfo info;
29059 int32_t xoff,yoff;
29060 1981371 zfix deltax(0), deltay(0);
29061 1981371 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
29062
2/2
✓ Branch 0 taken 1321940 times.
✓ Branch 1 taken 659431 times.
1981371 if(cmbid < 0)
29063 {
29064
2/2
✓ Branch 0 taken 1321884 times.
✓ Branch 1 taken 56 times.
1321940 if (conveyclk <= 0) is_on_conveyor=false;
29065 1321940 return;
29066 }
29067 659431 newcombo const* cmb = &combobuf[cmbid];
29068 659431 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
29069 659431 bool custom_spd = (cmb->usrflags&cflag2);
29070
3/4
✓ Branch 0 taken 659326 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 659326 times.
✗ Branch 3 not taken.
659431 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
29071 {
29072 659431 int32_t ctype=cmb->type;
29073
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 659326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
659431 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
29074
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 659326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
659431 if(custom_spd && (newconveyorclk % rate)) return;
29075
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 659337 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
659431 if((cmb->usrflags&cflag5) && HasHeavyBoots())
29076 return;
29077 659431 is_on_conveyor=false;
29078 659431 is_conveyor_stunned=0;
29079
29080 659431 deltax=combo_class_buf[ctype].conveyor_x_speed;
29081 659431 deltay=combo_class_buf[ctype].conveyor_y_speed;
29082
29083
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 659431 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659431 if (is_conveyor(ctype) && custom_spd)
29084 {
29085 deltax = zslongToFix(cmb->attributes[0]);
29086 deltay = zslongToFix(cmb->attributes[1]);
29087 }
29088
29089
6/8
✓ Branch 0 taken 659431 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659431 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2096 times.
✓ Branch 5 taken 657335 times.
✓ Branch 6 taken 757 times.
✓ Branch 7 taken 1339 times.
659431 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
29090 {
29091 1339 cmbid = MAPCOMBO(x+8,y+16);
29092 1339 cmb = &combobuf[cmbid];
29093 1339 custom_spd = cmb->usrflags&cflag2;
29094 1339 ctype=(cmb->type);
29095 1339 deltax=combo_class_buf[ctype].conveyor_x_speed;
29096 1339 deltay=combo_class_buf[ctype].conveyor_y_speed;
29097
2/4
✓ Branch 0 taken 1339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1339 times.
✗ Branch 3 not taken.
1339 if ((deltax != 0 || deltay != 0) && custom_spd)
29098 {
29099 deltax = zslongToFix(cmb->attributes[0]);
29100 deltay = zslongToFix(cmb->attributes[1]);
29101 }
29102 1339 }
29103
29104
2/4
✓ Branch 0 taken 659431 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659431 times.
659431 if(deltax!=0||deltay!=0)
29105 {
29106 is_on_conveyor=true;
29107 }
29108 659431 else return;
29109
29110 bool movedx = false, movedy = false;
29111 if(cmb->usrflags&cflag4) //Smart corners
29112 {
29113 if(deltay<0)
29114 {
29115 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29116 execute(info);
29117
29118 if(!info.isUnwalkable())
29119 {
29120 movedy = true;
29121 zfix step(0);
29122
29123 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29124 {
29125 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29126 {
29127 yoff=int32_t(y-step)&7;
29128
29129 if(!yoff) break;
29130
29131 step++;
29132 }
29133 }
29134 else
29135 {
29136 step=abs(deltay);
29137 }
29138
29139 y=y-step;
29140 hs_starty-=step.getInt();
29141
29142 for(int32_t j=0; j<chainlinks.Count(); j++)
29143 {
29144 chainlinks.spr(j)->y-=step;
29145 }
29146
29147 if(Lwpns.idFirst(wHookshot)>-1)
29148 {
29149 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29150 }
29151
29152 if(Lwpns.idFirst(wHSHandle)>-1)
29153 {
29154 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29155 }
29156 }
29157 }
29158 else if(deltay>0)
29159 {
29160 info = walkflag(x,y+15+2,2,down);
29161 execute(info);
29162
29163 if(!info.isUnwalkable())
29164 {
29165 movedy = true;
29166 zfix step(0);
29167
29168 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29169 {
29170 while(step<abs(deltay))
29171 {
29172 yoff=int32_t(y+step)&7;
29173
29174 if(!yoff) break;
29175
29176 step++;
29177 }
29178 }
29179 else
29180 {
29181 step=abs(deltay);
29182 }
29183
29184 y=y+step;
29185 hs_starty+=step.getInt();
29186
29187 for(int32_t j=0; j<chainlinks.Count(); j++)
29188 {
29189 chainlinks.spr(j)->y+=step;
29190 }
29191
29192 if(Lwpns.idFirst(wHookshot)>-1)
29193 {
29194 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29195 }
29196
29197 if(Lwpns.idFirst(wHSHandle)>-1)
29198 {
29199 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29200 }
29201 }
29202 }
29203
29204 if(deltax<0)
29205 {
29206 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29207 execute(info);
29208
29209 if(!info.isUnwalkable())
29210 {
29211 movedx = true;
29212 zfix step(0);
29213
29214 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29215 {
29216 while(step<abs(deltax))
29217 {
29218 xoff=int32_t(x-step)&7;
29219
29220 if(!xoff) break;
29221
29222 step++;
29223 }
29224 }
29225 else
29226 {
29227 step=abs(deltax);
29228 }
29229
29230 x=x-step;
29231 hs_startx-=step.getInt();
29232
29233 for(int32_t j=0; j<chainlinks.Count(); j++)
29234 {
29235 chainlinks.spr(j)->x-=step;
29236 }
29237
29238 if(Lwpns.idFirst(wHookshot)>-1)
29239 {
29240 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29241 }
29242
29243 if(Lwpns.idFirst(wHSHandle)>-1)
29244 {
29245 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29246 }
29247 }
29248 }
29249 else if(deltax>0)
29250 {
29251 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29252 execute(info);
29253
29254 if(!info.isUnwalkable())
29255 {
29256 movedx = true;
29257 zfix step(0);
29258
29259 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29260 {
29261 while(step<abs(deltax))
29262 {
29263 xoff=int32_t(x+step)&7;
29264
29265 if(!xoff) break;
29266
29267 step++;
29268 }
29269 }
29270 else
29271 {
29272 step=abs(deltax);
29273 }
29274
29275 x=x+step;
29276 hs_startx+=step.getInt();
29277
29278 for(int32_t j=0; j<chainlinks.Count(); j++)
29279 {
29280 chainlinks.spr(j)->x+=step;
29281 }
29282
29283 if(Lwpns.idFirst(wHookshot)>-1)
29284 {
29285 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29286 }
29287
29288 if(Lwpns.idFirst(wHSHandle)>-1)
29289 {
29290 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29291 }
29292 }
29293 }
29294 if(deltax && !movedx)
29295 y = COMBOY(pos);
29296 if(deltay && !movedy)
29297 x = COMBOX(pos);
29298 }
29299 if(!movedy)
29300 {
29301 if(deltay<0)
29302 {
29303 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29304 execute(info);
29305
29306 if(!info.isUnwalkable())
29307 {
29308 movedy = true;
29309 zfix step(0);
29310
29311 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29312 {
29313 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29314 {
29315 yoff=int32_t(y-step)&7;
29316
29317 if(!yoff) break;
29318
29319 step++;
29320 }
29321 }
29322 else
29323 {
29324 step=abs(deltay);
29325 }
29326
29327 y=y-step;
29328 hs_starty-=step.getInt();
29329
29330 for(int32_t j=0; j<chainlinks.Count(); j++)
29331 {
29332 chainlinks.spr(j)->y-=step;
29333 }
29334
29335 if(Lwpns.idFirst(wHookshot)>-1)
29336 {
29337 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29338 }
29339
29340 if(Lwpns.idFirst(wHSHandle)>-1)
29341 {
29342 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29343 }
29344 }
29345 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
29346 }
29347 else if(deltay>0)
29348 {
29349 info = walkflag(x,y+15+2,2,down);
29350 execute(info);
29351
29352 if(!info.isUnwalkable())
29353 {
29354 movedy = true;
29355 zfix step(0);
29356
29357 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29358 {
29359 while(step<abs(deltay))
29360 {
29361 yoff=int32_t(y+step)&7;
29362
29363 if(!yoff) break;
29364
29365 step++;
29366 }
29367 }
29368 else
29369 {
29370 step=abs(deltay);
29371 }
29372
29373 y=y+step;
29374 hs_starty+=step.getInt();
29375
29376 for(int32_t j=0; j<chainlinks.Count(); j++)
29377 {
29378 chainlinks.spr(j)->y+=step;
29379 }
29380
29381 if(Lwpns.idFirst(wHookshot)>-1)
29382 {
29383 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29384 }
29385
29386 if(Lwpns.idFirst(wHSHandle)>-1)
29387 {
29388 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29389 }
29390 }
29391 else checkdamagecombos(x,y+15);
29392 }
29393 }
29394 if(!movedx)
29395 {
29396 if(deltax<0)
29397 {
29398 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29399 execute(info);
29400
29401 if(!info.isUnwalkable())
29402 {
29403 movedx = true;
29404 zfix step(0);
29405
29406 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29407 {
29408 while(step<abs(deltax))
29409 {
29410 xoff=int32_t(x-step)&7;
29411
29412 if(!xoff) break;
29413
29414 step++;
29415 }
29416 }
29417 else
29418 {
29419 step=abs(deltax);
29420 }
29421
29422 x=x-step;
29423 hs_startx-=step.getInt();
29424
29425 for(int32_t j=0; j<chainlinks.Count(); j++)
29426 {
29427 chainlinks.spr(j)->x-=step;
29428 }
29429
29430 if(Lwpns.idFirst(wHookshot)>-1)
29431 {
29432 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29433 }
29434
29435 if(Lwpns.idFirst(wHSHandle)>-1)
29436 {
29437 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29438 }
29439 }
29440 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
29441 }
29442 else if(deltax>0)
29443 {
29444 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29445 execute(info);
29446
29447 if(!info.isUnwalkable())
29448 {
29449 movedx = true;
29450 zfix step(0);
29451
29452 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29453 {
29454 while(step<abs(deltax))
29455 {
29456 xoff=int32_t(x+step)&7;
29457
29458 if(!xoff) break;
29459
29460 step++;
29461 }
29462 }
29463 else
29464 {
29465 step=abs(deltax);
29466 }
29467
29468 x=x+step;
29469 hs_startx+=step.getInt();
29470
29471 for(int32_t j=0; j<chainlinks.Count(); j++)
29472 {
29473 chainlinks.spr(j)->x+=step;
29474 }
29475
29476 if(Lwpns.idFirst(wHookshot)>-1)
29477 {
29478 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29479 }
29480
29481 if(Lwpns.idFirst(wHSHandle)>-1)
29482 {
29483 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29484 }
29485 }
29486 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
29487 }
29488 }
29489 if(movedx || movedy)
29490 {
29491 if(cmb->usrflags&cflag1)
29492 is_conveyor_stunned = rate;
29493 if(cmb->usrflags&cflag3)
29494 {
29495 if(abs(deltax) > abs(deltay))
29496 dir = (deltax > 0) ? right : left;
29497 else dir = (deltay > 0) ? down : up;
29498 }
29499 }
29500 }
29501 1981852 }
29502
29503 void HeroClass::setNayrusLoveShieldClk(int32_t newclk)
29504 {
29505 NayrusLoveShieldClk=newclk;
29506
29507 if(decorations.idCount(dNAYRUSLOVESHIELD)==0)
29508 {
29509 decoration *dec;
29510 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29511 decorations.spr(decorations.Count()-1)->misc=0;
29512 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29513 dec=(decoration *)decorations.spr(decorations.Count()-1);
29514 decorations.spr(decorations.Count()-1)->misc=1;
29515 }
29516 }
29517
29518 3644 int32_t HeroClass::getNayrusLoveShieldClk()
29519 {
29520 3644 return NayrusLoveShieldClk;
29521 }
29522
29523 int32_t HeroClass::getHoverClk()
29524 {
29525 return hoverclk;
29526 }
29527
29528 376946 int32_t HeroClass::getHoldClk()
29529 {
29530 376946 return holdclk;
29531 }
29532
29533 1927786 int32_t HeroClass::getLastLensID(){
29534 1927786 return last_lens_id;
29535 }
29536
29537 26 void HeroClass::setLastLensID(int32_t p_item){
29538 26 last_lens_id = p_item;
29539 26 }
29540
29541 16400118 bool HeroClass::getOnSideviewLadder()
29542 {
29543 16400118 return on_sideview_ladder;
29544 }
29545
29546 52 void HeroClass::setOnSideviewLadder(bool val)
29547 {
29548
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 7 times.
52 if(val)
29549 {
29550 7 fall = fakefall = hoverclk = jumping = 0;
29551 7 hoverflags = 0;
29552 7 inair = false;
29553 7 }
29554 52 on_sideview_ladder = val;
29555 52 }
29556
29557 631045 bool HeroClass::canSideviewLadder(bool down)
29558 {
29559
2/2
✓ Branch 0 taken 629793 times.
✓ Branch 1 taken 1252 times.
631045 if(!isSideViewHero()) return false;
29560
1/2
✓ Branch 0 taken 1252 times.
✗ Branch 1 not taken.
1252 if(jumping < 0) return false;
29561
3/4
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 943 times.
✓ Branch 2 taken 309 times.
✗ Branch 3 not taken.
1252 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29562 {
29563 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29564 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
29565 }
29566 //Are you presently able to climb a sideview ladder?
29567 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29568 //y+0 checks your top-half for large hitbox; y+8 for small
29569 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29570 //y+16 check is for going down onto a ladder you are standing on.
29571
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 504 times.
1970 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
29572
4/4
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 646 times.
✓ Branch 3 taken 72 times.
748 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
29573
6/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 642 times.
✓ Branch 2 taken 333 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 305 times.
✓ Branch 5 taken 4 times.
955 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
29574 631045 }
29575
29576 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
29577 {
29578 if(!isSideViewHero()) return false;
29579 if(jumping < 0) return false;
29580 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29581 {
29582 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29583 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
29584 }
29585 //Are you presently able to climb a sideview ladder?
29586 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29587 //y+0 checks your top-half for large hitbox; y+8 for small
29588 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29589 //y+16 check is for going down onto a ladder you are standing on.
29590 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
29591 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
29592 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
29593 }
29594
29595 1202648 void HeroClass::execute(HeroClass::WalkflagInfo info)
29596 {
29597 1202648 int32_t flags = info.getFlags();
29598
29599
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1202576 times.
1202648 if(flags & WalkflagInfo::CLEARILSWIM)
29600 72 ilswim =false;
29601
2/2
✓ Branch 0 taken 1202548 times.
✓ Branch 1 taken 28 times.
1202576 else if(flags & WalkflagInfo::SETILSWIM)
29602 28 ilswim = true;
29603
29604
1/2
✓ Branch 0 taken 1202648 times.
✗ Branch 1 not taken.
1202648 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
29605 {
29606 charging = 0;
29607 attackclk = 0;
29608 }
29609
29610
1/2
✓ Branch 0 taken 1202648 times.
✗ Branch 1 not taken.
1202648 if(flags & WalkflagInfo::SETDIR)
29611 {
29612 dir = info.getDir();
29613 }
29614
29615
2/2
✓ Branch 0 taken 1202591 times.
✓ Branch 1 taken 57 times.
1202648 if(flags & WalkflagInfo::SETHOPCLK)
29616 {
29617 57 hopclk = info.getHopClk();
29618 57 }
29619
29620
2/2
✓ Branch 0 taken 1202620 times.
✓ Branch 1 taken 28 times.
1202648 if(flags & WalkflagInfo::SETHOPDIR)
29621 {
29622 28 hopdir = info.getHopDir();
29623 28 }
29624
29625 1202648 }
29626
29627 2516390 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
29628 {
29629 2516390 HeroClass::WalkflagInfo ret;
29630 2516390 ret.newhopclk = newhopclk;
29631 2516390 ret.newdir = newdir;
29632
2/2
✓ Branch 0 taken 2003636 times.
✓ Branch 1 taken 512754 times.
2516390 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29633
29634 2516390 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
29635 2516390 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
29636 2516390 ret.flags = flags1 | flags2;
29637 2516390 return ret;
29638 }
29639
29640 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
29641 {
29642 HeroClass::WalkflagInfo ret;
29643 ret.newhopclk = newhopclk;
29644 ret.newdir = newdir;
29645 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29646
29647 ret.flags = flags & other.flags;
29648 return ret;
29649 }
29650
29651 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
29652 {
29653 HeroClass::WalkflagInfo ret;
29654 ret.newhopclk = newhopclk;
29655 ret.newdir = newdir;
29656 ret.newhopdir = newhopdir;
29657
29658 ret.flags = flags ^ UNWALKABLE;
29659 return ret;
29660 }
29661
29662 void HeroClass::explode(int32_t type)
29663 {
29664 static int32_t tempx, tempy;
29665 static byte herotilebuf[256];
29666 int32_t ltile=0;
29667 int32_t lflip=0;
29668 bool shieldModify=true;
29669 unpack_tile(newtilebuf, tile, flip, true);
29670 memcpy(herotilebuf, unpackbuf, 256);
29671 tempx=Hero.getX();
29672 tempy=Hero.getY();
29673 for(int32_t i=0; i<16; ++i)
29674 {
29675 for(int32_t j=0; j<16; ++j)
29676 {
29677 if(herotilebuf[i*16+j])
29678 {
29679 if(type==0) // Twilight
29680 {
29681 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
29682 int32_t k=particles.Count()-1;
29683 particle *p = (particles.at(k));
29684 p->step=3;
29685 }
29686 else if(type ==1) // Sands of Hours
29687 {
29688 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
29689 int32_t k=particles.Count()-1;
29690 particle *p = (particles.at(k));
29691 p->step=4;
29692
29693 if(zc_oldrand()%10 < 2)
29694 {
29695 p->color=1;
29696 p->cset=0;
29697 }
29698 }
29699 else
29700 {
29701 particles.add(new pFaroresWindDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
29702
29703 int32_t k=particles.Count()-1;
29704 particle *p = (particles.at(k));
29705 p->angular=true;
29706 p->angle=zc_oldrand();
29707 p->step=(((double)j)/8);
29708 p->yofs=Hero.getYOfs();
29709 }
29710 }
29711 }
29712 }
29713 }
29714
29715 104 void HeroClass::SetSwim()
29716 {
29717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (CanSideSwim())
29718 {
29719 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
29720 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29721 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
29722 }
29723 104 else {action=swimming; FFCore.setHeroAction(swimming);}
29724 104 }
29725
29726 24938 void HeroClass::SetAttack()
29727 {
29728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24938 times.
24938 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29729 24938 else {action=attacking; FFCore.setHeroAction(attacking);}
29730 24938 }
29731
29732 16395304 bool HeroClass::IsSideSwim()
29733 {
29734
6/12
✓ Branch 0 taken 16395304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16395304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16395304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16395304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16395304 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 16395304 times.
16395304 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
29735 }
29736
29737 478515 bool HeroClass::CanSideSwim()
29738 {
29739
1/2
✓ Branch 0 taken 478515 times.
✗ Branch 1 not taken.
478515 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
29740 }
29741
29742 1440627 int32_t HeroClass::getTileModifier()
29743 {
29744 1440627 return item_tile_mod() + bunny_tile_mod();
29745 }
29746 void HeroClass::setImmortal(int32_t nimmortal)
29747 {
29748 immortal = nimmortal;
29749 }
29750 void HeroClass::kill(bool bypassFairy)
29751 {
29752 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
29753 }
29754 3970395 bool HeroClass::sideview_mode() const
29755 {
29756
3/4
✓ Branch 0 taken 16318 times.
✓ Branch 1 taken 3954077 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16318 times.
3970395 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
29757 }
29758 3851 bool HeroClass::is_unpushable() const
29759 {
29760 3851 return toogam;
29761 }
29762 /*** end of hero.cpp ***/
29763
29764
29765
29766
29767